Wednesday 15 September 2010

Array filter php multi dimensional array -


Has the array method used to filter nested associative array in PHP?

For example: Array = array (array ('key1' =>), array ('key1' = & gt; 'value1') , Array ('key1' = & gt; 'value2'););

I want to remove any more empty value - the first element in this example.

I know that array_filter will have to do something with a similar array, but can not find anything other than looping and besides creating my own new array, if it is the best solution then ok, I myself I can do this. I just did not want to ignore a built-in method for this.

  $ myArray = array_filter ($ myArray, function ($ el) {return! Empty $ El ['key1']);});    

No comments:

Post a Comment