2016-08-08 82 views
0

這裏是我的陣列,我要動態刪除:如何從php中的大數組中刪除子數組?

Array (
    [fields] => ID 
    [number] => 0 
    [meta_query] => Array (
     [relation] => AND 
     [0] => Array (
      [key] => role 
      [value] => Array (
       [0] => subscriber 
       [1] => author 
       [2] => custom-one 
       [3] => custom-two 
      ) 
      [compare] => IN 
     ) 
     [1] => Array (
      [key] => country 
      [value] => United States 
      [compare] => = 
     ) 
     [2] => Array (
      [key] => near_by_place 
      [value] => someplace 
      [compare] => LIKE 
     ) 
    ) 
    [order] => ASC 
    [meta_key] => last_name 
    [orderby] => meta_value 
) 

我想刪除以下(其中[key] => near_by_place):

[2] => Array (
    [key] => near_by_place 
    [value] => someplace 
    [compare] => LIKE 
) 

這可以是任何指標,目前其對指數2但它可以在1,2,3或4或任何。

+0

你爲什麼不只是使用_unset()_? –

+1

什麼是要刪除的搜索條件? – Saurabh

+1

你怎麼知道哪一個要刪除?鍵/值總是與你想刪除的那個相同? –

回答