Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Delete value from a mutidimensional array

$
0
0

Hi All,

 

I have been unsuccessfully trying to find a solution to delete a value from a multidimensional array. I found some tips here and there (e.g. http://stackoverflow.com/questions/4466159/delete-element-from-multidimensional-array-based-on-value), but was not able to adapt it to my case.

 

Basically, let say we have this initial print_r :

 

Array
(
    [v0] => Array
        (
            [w1] => Array
                (
                    [x2] => Array
                        (
                            [y3] => Array
                                (
                                    [0] => hello
                                    [1] => world
                                )
                        )
                )
        )
)

I want to find the value "world", and delete it so that the array looks like this :

 

Array
(
    [v0] => Array
        (
            [w1] => Array
                (
                    [x2] => Array
                        (
                            [y3] => Array
                                (
                                    [0] => hello
                                )
                        )
                )
        )
)

The data initially known are the array name and the value to look for.

Note that a given sub-array will contain only one sub-array or only one or more values.

 

Thanks for your help !

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles