My code is :
<?php
$arr = array();
array_push($arr,"One","Two","Three");
print_r($arr);
echo '<br>';
echo json_encode($arr);
?>
As you can see, I'm passing a non-associative array to json_encode()
. The Output I get is
Array ( [0] => One [1] => Two [2] => Three )
["One","Two","Three"]
What exactly is the second line of the output? If we pass an associative array to json_encode()
, what is returned is a JSON Object, but this array that is returned is definitely does not look like a JSON object. So what is it?
Also, is there a way to convert a non-associative array to a JSON Object using json_encode()
?