Skip to content Skip to sidebar Skip to footer

How To Read Json Array Using Php?

I'm looking to read JSON array using PHP. I'm using php file_get_contents to read the JSON array. So, here is how my array look like, Can anyone tell me how can I read all the arra

Solution 1:

return your array with json_encode($array) it will return a JSON Object.

Solution 2:

Building on @mohamed-nizar,

filename.php:

<html><head><script>var json = <?php json_encode(file_get_contents('array.php')); ?>;
</script></head><body></body></html>

For converting JSON to and Javascript Array(), check this thread: How to convert JSON to Array But there's really no reason to do so, it's better to just use the JSON.

Post a Comment for "How To Read Json Array Using Php?"