Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

how do I set keys for JSONObjects in PHP

json_encode isn't actually setting any indices of your JSON object, you are doing so in PHP. json_encode just takes the structure you provide it, and converts it to a string in valid JSON (if possible).

What you need to do is instead of using array_push($row, $width), do something along the lines of: $row['width'] = $width;, and the same for $height. Then your $row array will have the key width that points to the variable $width, and json_encode will encode it appropriately.

Categories : PHP

Related to : how do I set keys for JSONObjects in PHP
Recently Add
Cartesian product of associative array showing key and value - PHP
Datamapper orm save and update not working
find methods in COM object
PHP Keyword search not working with multiple words
Set a total based on items ordered, two types, and sometimes one type will not be ordered.
FB request to join a group, going around their official SDK
Using Google charts with php data?
OAuth2 integration with ExactOnline
libvirt-php receives the error: unable to connect to server Permission denied
How to echo results by sets of 2?
Why does PHP's sprintf not round 5s reliably?
php replace affects on replaced string
PHP Find and replace multiple similar entries
Replace PHP date output with pre-made images
How to install Laravel 4 packages on Windows
Using updateOrCreate for multiple data insert in Laravel
Storing products in a MYSQL database and then search and filter them?
Create order with PrestaShop's API
how to get latest messages from all users
Yii CMultiFileUpload Restrict Image width
Combine array by key factor
Semicolon after if condition in PHP - code still works
Get date using day of the week
soap web service with symfony
Seasonal Reservation system Day/month
is it possible to join a single table it self?
Attempting to compare two arrays PHP
Sticky Select Option
Eventbrite duplicate event entry
Pagination Not Working on custom post type in Wordpress
© Copyright 2017 Publishing Limited. All rights reserved.