Page 1 of 1

Deleting values from an array

Posted: Thu Apr 10, 2008 5:41 am
by aceconcepts
Hi,

I have the following array: Array ( [0] => Array ( [1] => Array ( [0] => 1 [1] => 4 ) ) )

What I am trying to do is delete a specific value from this array e.g. sya I need to delete the value 4 from the third nested array, how could I do this without effecting the rest of the arrays?

Thanks.

Re: Deleting values from an array

Posted: Thu Apr 10, 2008 5:48 am
by EverLearning
You unset by providing the path to the array element that contains value 4(you access array values by keys)

Code: Select all

unset($array[0][1][1]);