【发布时间】:2018-08-12 17:40:03
【问题描述】:
我想在搜索参数中使用循环,如下所示
$community = array("eleven_polls", "activities_coordinator", "attractively_priced_onsite_laundry_care_centers");
$community_count = count($community);
$args = array(
'numberposts' => -1,
'post_type' => 'apartment',
'meta_query' => array(
'relation' => 'AND',
array(
'relation' => 'AND',
for ($i=0; $i < $community_count ; $i++) {
array(
'key' => 'community',
'value' => $_GET['community'][$i],
'compare' => 'LIKE'
),
}
)
)
);
但它在 for 循环行显示语法错误,我如何在数组内运行 for 循环
【问题讨论】:
-
不能在数组中执行循环
-
但是如何实现我想要的,你有什么想法吗? @Mr.Developer
-
您应该在数组关闭后删除逗号 (,)。
标签: php arrays wordpress for-loop