Friday, May 31, 2019

php - How to delete an array element based on key?






Possible Duplicate:
How to delete an element from an array in php?






For instance,




Array(      
[0] => Array
(
[0] => hello
[1] => open
)

[1] => Array
(

[0] => good
[1] => center
)

[2] => Array
(
[0] => hello
[1] => close
)
)



I want to delete the element which key is 1, after the operation:



Array(
[0] => Array
(
[0] => hello
[1] => open
)


[2] => Array
(
[0] => hello
[1] => close
)
)

Answer



PHP




unset($array[1]);

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...