How to return JSON from a script in PHP

1 Answer

0 votes
$array = array("a" => "php", "b" => "c++", "c" => "java", "d" => "python");

header("Content-Type: application/json");

echo json_encode($array);

exit();




/*
run:

{"a":"php","b":"c++","c":"java","d":"python"}

*/

 



answered Jun 29, 2022 by avibootz

Related questions

1 answer 279 views
1 answer 279 views
1 answer 268 views
1 answer 209 views
...