从php对象中提取数组
嗨,我有以下我用print\r打印的对象从php对象中提取数组,php,Php,嗨,我有以下我用print\r打印的对象 Facebook\GraphObject Object ( [backingData:protected] => Array ( [id] => xxxxxxxxxx [first_name] => xxx [gender] => xxx [last_name] => xxx [link] => https://ww
Facebook\GraphObject Object (
[backingData:protected] => Array ( [id] => xxxxxxxxxx
[first_name] => xxx
[gender] => xxx
[last_name] => xxx
[link] => https://www.facebook.com/app_scoped_user_id/xxxxxxxxxx/
[locale] => fr_FR
[name] => xxx [timezone] => x
[updated_time] => xxx
[verified] => x ) )
我可以用来从这个对象提取数组的写入代码是什么有一个asArray()
方法可用。因此:
$arr = $obj->asArray();
参考资料:
function get_Array()
{
return $this->backingData;
}
$Array = $Obj->get_Array();
$id = $Array['id'] ;
$first_name = $Array['frist_name'];
您可以像这样获得所需的阵列
function get_Array()
{
return $this->backingData;
}
$Array = $Obj->get_Array();
$id = $Array['id'] ;
$first_name = $Array['frist_name'];
您是要提取对象内部的特定数组,还是要将整个对象转换为数组?@Khalid我要提取包含id、first_name、。。。。。。。。所有这些