How to convert array into json API in PHP || how to use json encode and decode in PHP.
-
Neel Bhardwaj
-
15-Jan-2022
-
0 comments
-
171
In API json is the most important. All data send in json formate.
So it's important to you to know how json work.
Here is the simple example of json :
{
"name" : "anonymous'
}
Actually its object type. Key=Value pair.
So here is the question. How to convert array into json formate in PHP.
In PHP there is default function given which convert ARRAY=JSON
json_encode()
EG :
$some_array = [
"name" => "anonymous"
]
So convert this array into json. Simply use json_encode();
json_encode($some_array);
Result :
{
"name" : "anonymous'
}
"Programming isn't about what you know,
it's about what you can figure out.”
Leave a reply
Thanks for comment. Your comment are shown after approve by ADMIN. THANKS!!
There is some server issue. Please try again. THANKS!!
Fatal error: Cannot declare class Connection, because the name is already in use in /home/d8ouyzxnuef4/public_html/thecoderjob.com/cj_admin/classes/Connection.php on line 3
Recent comments