Всем привет, нужно достать url из массива Код (Text): object(stdClass)#16 (1) { ["response"]=> object(stdClass)#1 (2) { ["count"]=> int(24019) ["items"]=> array(2) { [0]=> object(stdClass)#2 (12) { ["date"]=> int(1593544477) ["from_id"]=> int(221906343) ["id"]=> int(1580029) ["out"]=> int(1) ["peer_id"]=> int(215159528) ["text"]=> string(38) "проверка" ["conversation_message_id"]=> int(26621) ["fwd_messages"]=> array(0) { } ["important"]=> bool(false) ["random_id"]=> int(2039699697) ["attachments"]=> array(0) { } ["is_hidden"]=> bool(false) } [1]=> object(stdClass)#3 (12) { ["date"]=> int(1593544469) ["from_id"]=> int(221906343) ["id"]=> int(1580028) ["out"]=> int(1) ["peer_id"]=> int(215159528) ["text"]=> string(0) "" ["conversation_message_id"]=> int(26620) ["fwd_messages"]=> array(0) { } ["important"]=> bool(false) ["random_id"]=> int(908125352) ["attachments"]=> array(1) { [0]=> object(stdClass)#4 (2) { ["type"]=> string(5) "photo" ["photo"]=> object(stdClass)#5 (8) { ["album_id"]=> int(-6) ["date"]=> int(1580396874) ["id"]=> int(457241299) ["owner_id"]=> int(221906343) ["has_tags"]=> bool(false) ["post_id"]=> int(453) ["sizes"]=> array(10) { [0]=> object(stdClass)#6 (4) { ["height"]=> int(130) ["url"]=> string(69) "https://sun1-25.userapi.com/c854016/v854016756/1e450b/vvMIkVG_-sw.jpg" ["type"]=> string(1) "m" ["width"]=> int(97) } [1]=> object(stdClass)#7 (4) { ["height"]=> int(173) ["url"]=> string(69) "https://sun1-91.userapi.com/c854016/v854016756/1e4510/nImt-ave0I4.jpg" ["type"]=> string(1) "o" ["width"]=> int(130) } [2]=> object(stdClass)#8 (4) { ["height"]=> int(267) ["url"]=> string(69) "https://sun1-27.userapi.com/c854016/v854016756/1e4511/GZnsT-svaek.jpg" ["type"]=> string(1) "p" ["width"]=> int(200) } [3]=> object(stdClass)#9 (4) { ["height"]=> int(427) ["url"]=> string(69) "https://sun1-20.userapi.com/c854016/v854016756/1e4512/nIeKY0mCbq4.jpg" ["type"]=> string(1) "q" ["width"]=> int(320) } [4]=> object(stdClass)#10 (4) { ["height"]=> int(681) ["url"]=> string(69) "https://sun1-95.userapi.com/c854016/v854016756/1e4513/YIvwui8uztI.jpg" ["type"]=> string(1) "r" ["width"]=> int(510) } [5]=> object(stdClass)#11 (4) { ["height"]=> int(75) ["url"]=> string(69) "https://sun1-47.userapi.com/c854016/v854016756/1e450a/EktoazsNkXs.jpg" ["type"]=> string(1) "s" ["width"]=> int(56) } [6]=> object(stdClass)#12 (4) { ["height"]=> int(1280) ["url"]=> string(69) "https://sun1-84.userapi.com/c854016/v854016756/1e450f/Thcl8PuH6Pc.jpg" ["type"]=> string(1) "w" ["width"]=> int(959) } [7]=> object(stdClass)#13 (4) { ["height"]=> int(604) ["url"]=> string(69) "https://sun1-18.userapi.com/c854016/v854016756/1e450c/YICDExUiGBo.jpg" ["type"]=> string(1) "x" ["width"]=> int(453) } [8]=> object(stdClass)#14 (4) { ["height"]=> int(807) ["url"]=> string(69) "https://sun1-15.userapi.com/c854016/v854016756/1e450d/75lD5-KlEB4.jpg" ["type"]=> string(1) "y" ["width"]=> int(605) } [9]=> object(stdClass)#15 (4) { ["height"]=> int(1080) ["url"]=> string(69) "https://sun1-94.userapi.com/c854016/v854016756/1e450e/oe17adnrKDY.jpg" ["type"]=> string(1) "z" ["width"]=> int(809) } } ["text"]=> string(0) "" } } } ["is_hidden"]=> bool(false) } } } } Делаю ( неправильно ) Код (Text): $json->response->items[0]->attachments[0]->photo->sizes[0]->url;
В целом правильно. Просто в attachments[0] пустой массив, нужно предусматривать это... А вот уже в attachments [1] все есть