Я разрабатываю приложение PHP, и у меня есть следующий массив: print_r($array)
Array (
[0] => stdClass Object (
[can_see_custom_stories] => 1
[name] => caitlinhamm
[display] =>
[type] => 3
)
[1] => stdClass Object (
[can_see_custom_stories] => 1
[name] => vladhq
[display] =>
[type] => 0
)
[2] => stdClass Object ( [can_see_custom_stories] => 1 [name] => interne [display] => Vlad [type] => 0 )
[3] => stdClass Object ( [can_see_custom_stories] => 1 [name] => frankiedoyle30 [display] => [type] => 0 )
[4] => stdClass Object ( [can_see_custom_stories] => 1 [name] => ayyeitskenzie03 [display] => [type] => 0 )
[5] => stdClass Object ( [can_see_custom_stories] => 1 [name] => laynedawwg [display] => Layne [type] => 0 )
[6] => stdClass Object ( [can_see_custom_stories] => 1 [name] => sarah.murphy225 [display] => [type] => 1 )
[7] => stdClass Object ( [can_see_custom_stories] => 1 [name] => rath1 [display] => Rathwaan [type] => 0 )
[8] => stdClass Object ( [can_see_custom_stories] => 1 [name] => brittanyyo [display] => Brit [type] => 0 )
[9] => stdClass Object ( [can_see_custom_stories] => 1 [name] => teamsnapchat [display] => Snapchat [type] => 0 )
[10] => stdClass Object ( [can_see_custom_stories] => 1 [name] => falconpunch1209 [display] => Colin Parker [type] => 0 )
[11] => stdClass Object ( [can_see_custom_stories] => 1 [name] => shawn_bonds [display] => Shawn Bonds [type] => 0 )
[12] => stdClass Object ( [can_see_custom_stories] => 1 [name] => chrisknowles [display] => Chris [type] => 0 )
[13] => stdClass Object ( [can_see_custom_stories] => 1 [name] => pypereronipizza [display] => [type] => 0 )
[14] => stdClass Object ( [can_see_custom_stories] => 1 [name] => wannaknow123 [display] => [type] => 0 )
[15] => stdClass Object ( [can_see_custom_stories] => 1 [name] => zainthugmalik [display] => Zain [type] => 1 )
[16] => stdClass Object ( [can_see_custom_stories] => 1 [name] => quinlanjade [display] => Quin [type] => 1 )
)
Я хочу передать это как легко без каких-либо операторов foreach()
.
Таким образом, массив $snapchat->getFriends()
. Могу ли я сделать что-то вроде:
$user = 'shawn_bonds';
$display = $snapchat->getFriends()->name['shawn_bonds']->display;
Как я могу получить отображаемое имя на основе исходного имени?
Спасибо!