convert array to json php – How to convert php array to json object with example?

convert array to json php – Convert the request into an object, using the PHP function json_decode(). json_encode is available in php > 5.2.0: echo json_encode ($dataResult);

convert array to json php

The json_encode() function is used to encode a value to JSON format. It is an inbuild php function that is used to convert PHP array or object into JSON representation.

Example 1: Converting PHP result array to JSON



Example 2: PHP json_encode: How to Convert PHP Array to JSON



Example 3: Converting an array to JSON data with PHP

'Dipti', 'website'=>''];
  $jsoninfo = json_encode($info);
  echo $jsoninfo;



Don’t Miss : PHP Converting An Array To JSON Tutorial With Example

I hope you get an idea about convert array to json php.
I would like to have feedback on my
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment