First, sorry if my problem is duplicated but I really try a lot of things but with no result. Second, my problem is that after using "json_encode($php_array)" and insert it into a js variable the output is "[object Object]" and it is not the $php_array.
Using key with the array (Bad result)
<script type="text/javascript">
// Some functions here
<?php
$php_array = array('name'=>'joe','10','cat');
$js_array = json_encode($php_array);
echo "var javascript_array = ". $js_array . ";
";
?>
alert(javascript_array); // Output is: [object Object]
</script
Without using key (Good result)
<script type="text/javascript">
// Some functions here
<?php
$php_array = array('joe','10','cat');
$js_array = json_encode($php_array);
echo "var javascript_array = ". $js_array . ";
";
?>
alert(javascript_array); // Output is: abc,def,ghi
</script
I expect the output of [{"name":"joe","cat"}], but the output is [object Object]