Карта сайта Интеллектуальная поисковая системаДобавить свою ссылку по ключевому запросуПоисковая система v3.kz поможет ускорить индексацию вашего сайта выводит в Топ |
|
I would imagine that the simplest thing to do is to decode into associative arrays instead of stdClass objects. $obj2 = json_decode( $json, true ); Foreach ( $obj2[streets] as $coords => $street ) {. Access json object in php [duplicate]. up vote -1 down vote favorite. If you are using json_decode($json,true); - true means returning the js objects results as associative arrays - then all you have to do is $user_info = $jsonDecoded[USER]; without the array() cast cause that is what json_decode do for you. thats not json. thats a var_dump of a PHP object, which contains somewher a json STRING. you cannot access that strings components as an object until AFTER its been decoded. This will work: Echo $object->feed->{xmlns$media}; Alternatively, you can tell json_decode to return an array: $array = json_decode($json, true); echo $array[feed][xmlns$media]; Contents Аргументы: $json — строка в формате JSON; $assoc — если равно true — функция вернет ассоциативный массив (array), иначе — объект (object); $depth A note of caution: If you are wondering why json_encode() encodes your PHP array as a JSON object instead of a JSON array, you might want to double check your array keys JavaScript, JSON, AJAX & PHP. Create & Access JSON Object in JavaScript. ?> Note the differences in accessing the values of an array vs an object. Convert PHP Array or Object to JSON String. PHP also features a json_encode function to convert an array or object into a string. Информация взята v3.kz |
загрузка...
|