如何从以下数组中检索[terms]的值来构成字符串(20,21,22 ...,n)?非常感谢您的帮助。
Array
(
[post_type] => Array
(
[0] => hotel
)
[posts_per_page] => 15
[tax_query] => Array
(
[0] => Array
(
[taxonomy] => facility
[field] => id
[terms] => 20
)
[1] => Array
(
[taxonomy] => facility
[field] => id
[terms] => 21
)
[2] => Array
(
[taxonomy] => facility
[field] => id
[terms] => 22
)
.
.
.
[*n*] => Array
(
[taxonomy] => facility
[field] => id
[terms] => *n*
)
[relation] => AND
)
[orderby] => title
[order] => ASC
[post_status] => publish
[paged] => 1
)
答案 0 :(得分:1)
试试这个:
$terms = array();
foreach( $array['tax_query'] as $item)
$terms[] = $item['terms'];
echo '(' . implode( ',', $terms) . ')';