2012-06-01 34 views
-2

如何從下列數組中檢索[terms]的值以組成字符串(20,21,22 ...,n)?我們非常感謝您的幫助。獲取數組3的深度值

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 
) 
+2

你應該閱讀的PHP教程。您使用數組索引操作符'[]'。 – meagar

回答

1

試試這個:

$terms = array(); 
foreach($array['tax_query'] as $item) 
    $terms[] = $item['terms']; 

echo '(' . implode(',', $terms) . ')';