How can I remove a sub array from a big array in php? -
this question has answer here:
- how filter array condition 7 answers
here array, want remove dynamically:
array ( [fields] => id [number] => 0 [meta_query] => array ( [relation] => , [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] => ) ) [order] => asc [meta_key] => last_name [orderby] => meta_value )
i want remove following (where [key] => near_by_place
):
[2] => array ( [key] => near_by_place [value] => someplace [compare] => )
this can in index , right on index 2 can on 1,2,3 or 4 or any.
assuming array called $values:
$values = array_slice($values, 2, 1);
more info here: http://php.net/manual/en/function.array-slice.php
Comments
Post a Comment