In fact. I came up with two ways to do this. It depends on how you are going to deal with the index problem.
If you want to leave indices after removing certain elements from the array, you will need unset ().
<?php $array = array("Tom","Jack","Rick","Alex");
Output:
Array ( [0] => Tom [1] => Jack [3] => Alex )
However, if you need a new array without saving the previous indexes, use array_splice ():
<?php $array = array("Tom","Jack","Rick","Alex");
The output this time:
Array ( [0] => Tom [1] => Jack [2] => Alex )
Hope this helps!
zhujy_8833
source share