访问在PHP多级阵列的较低值 [英] Accessing lower values of multilevel array in PHP
本文介绍了访问在PHP多级阵列的较低值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有对象的PHP数组,想轻松搞定所有POST_ID值。我已经调查之类的东西array_values和真的不知道如何处理这个事情。是只使用一个for循环,每个POST_ID添加到另一个阵列的所有岗位IDS的最佳方式?
I have a PHP array of objects and would like to get all the post_id values easily. I have looked into things like array_values and am not really sure what to do with this. Is the best way to just use a for loop and add each post_id to another array with all the post ids?
感谢您的帮助!
[0] => stdClass Object
(
[post_id] => 70242
[image_id] => 70244
[large_image] => 0
)
[1] => stdClass Object
(
[post_id] => 70327
[image_id] => 70339
[large_image] => 1
)
[2] => stdClass Object
(
[post_id] => 70017
[image_id] => 70212
[large_image] => 1
)
编辑:
我得到这个数组从Word preSS分贝的呼叫:
I am getting this array from a WordPress db call:
$q = <<<SQL
SELECT post_id, image_id, large_image
FROM $homepage_db
ORDER BY position;
SQL;
$results = $wpdb->get_results($q);
然后 $结果
大于
推荐答案
只需使用的foreach
循环
foreach($result_object as $item){
$post_id_array[] = $item->post_id;
}
这篇关于访问在PHP多级阵列的较低值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文