从数组的第二层获取 ID 值
Getting ID value from second level of Array
我确定这是一个非常新手的问题,但我被卡住了。
$apinstaller = get_sub_field_object("installer", "user_{$userid}");
print_r($apinstaller);
当我打印这个 $apinstaller 数组时,我看到了这个...
Array ( [ID] => 1297 [key] => field_5e9b6d60c718e [label] => Installer [name] => appointment_0_installer [prefix] => acf [type] => post_object [值] => WP_Post 对象 ( [ID] => 303 [post_author] => 1 [post_date] => 2017-12-29 07:17:22 [post_date_gmt] => 2017-12-29 07:17:22 [post_content] =>
$installerid = $apinstaller['ID'];
因此,当我回显 $installerID 时,我得到“1297”,而实际上我想要得到“303”,您可以看到它在该数组中,但作为 WP_Post 对象的一部分。
如何定位数组的那部分?
你可以看到这样的303
$installerid = $apinstaller['value']->ID;
我确定这是一个非常新手的问题,但我被卡住了。
$apinstaller = get_sub_field_object("installer", "user_{$userid}");
print_r($apinstaller);
当我打印这个 $apinstaller 数组时,我看到了这个...
Array ( [ID] => 1297 [key] => field_5e9b6d60c718e [label] => Installer [name] => appointment_0_installer [prefix] => acf [type] => post_object [值] => WP_Post 对象 ( [ID] => 303 [post_author] => 1 [post_date] => 2017-12-29 07:17:22 [post_date_gmt] => 2017-12-29 07:17:22 [post_content] =>
$installerid = $apinstaller['ID'];
因此,当我回显 $installerID 时,我得到“1297”,而实际上我想要得到“303”,您可以看到它在该数组中,但作为 WP_Post 对象的一部分。
如何定位数组的那部分?
你可以看到这样的303
$installerid = $apinstaller['value']->ID;