i passed a json_encode
d array to javascript. Now i would like to acces that array to get the different elemtnts.
i print it out in the console.log()
and i get this array:
array(1) {
[16]=>
array(2) {
[3488]=>
array(1) {
[0]=>
array(2) {
["article_no_internal"]=>
string(6) "999184"
["article_name_internal"]=>
string(29) "Geschenkbox Kerzenschein 2011"
}
}
[2615]=>
array(1) {
[0]=>
array(2) {
["article_no_internal"]=>
string(6) "700469"
["article_name_internal"]=>
string(29) "Hotelscheck RomantischeTagef2"
}
}
}
}
This is about right. How can i access the article_name of the second array, with the ID 2615?
found a related question here reading a jsone object, hope for some better explebation or answer. Thanks.
EDIT:
As it seems i made a mistake, i showed a php var_dump in the console. When i try to show the javascript array in the console i get undefined.
console.log
?! That looks likevar_dump
in PHP. How exactly are you passing that array? – deceze Aug 29 '12 at 10:55$shipping_part_list_array = json_encode($db_obj->getArticleList($elements),true);
and how i pass to javascript:var array = <?php echo $shipping_part_list_array; ?>;
in the console now i have undefined. – Barta Tamás Aug 29 '12 at 11:02var array = <?php echo json_encode($shipping_part_list_array); ?>;
it says there are no childe objects. – Barta Tamás Aug 29 '12 at 11:43