There are 2 functions involved.
$array = array("first", "second", "third", "fourth");
foreach($array as $i=> $string) {
if(stristr($string, "e")) {
unset($array[$i]);
}
}
Run Code Online (Sandbox Code Playgroud)
second是具有字符"e"的数组项.如果它unset,$array[1]将留空:
$array[0] = "first"
$array[1] = ""
$array[2] = "third"
$array[3] = "fourth"
Run Code Online (Sandbox Code Playgroud)
我想$array[1]从阵列(如在除去array_shift()),从而使third需要的地方second和fourth的地方third:
$array[0] = "first"
$array[1] = "third"
$array[2] = "fourth"
Run Code Online (Sandbox Code Playgroud)