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 array?
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 array?
return your array with json_encode($array)
it will return a JSON Object.
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.