所有
我正在使用这个foreach循环
foreach ($entries as $entry)
{
global $wpdb;
//$pname = $wpdb->get_var("SELECT meta_value FROM wp_frm_item_metas WHERE (field_id=228 && item_id=$entry->id) OR (field_id=301 && item_id=$entry->id) OR (field_id=120 && item_id=$entry->id)");
$pname1 = $wpdb->get_results("SELECT id FROM wp_frm_item_metas WHERE (field_id=(SELECT id FROM wp_frm_fields WHERE field_key ='$field_key') && item_id=$entry->id)");
echo "<pre>";
print_r($pname1);
echo "</pre>";
}
结果是
Array
(
[0] => stdClass Object
(
[id] => 984
)
)
Array
(
[0] => stdClass Object
(
[id] => 1047
)
)
Array
(
[0] => stdClass Object
(
[id] => 1077
)
)
我想在单个数组中使用它。 我试过了......
$genreArray=array();
foreach ($entries as $entry)
{
global $wpdb;
//$pname = $wpdb->get_var("SELECT meta_value FROM wp_frm_item_metas WHERE (field_id=228 && item_id=$entry->id) OR (field_id=301 && item_id=$entry->id) OR (field_id=120 && item_id=$entry->id)");
$pname1 = $wpdb->get_results("SELECT id FROM wp_frm_item_metas WHERE (field_id=(SELECT id FROM wp_frm_fields WHERE field_key ='$field_key') && item_id=$entry->id)");
$result = array_merge_recursive($genreArray, $pname1);
}
但是,它只显示数组的最后一个值。
答案 0 :(得分:1)
$genreArray = array_merge_recursive($genreArray, $pname1);