How to remove specific items from a PHP array?
You can use the unset() function in PHP to remove a specific item from an array. The unset() function is used to free up memory space for a specified variable. Here is an example code for removing a specific item from an array:
<?php
$fruits = array("apple", "banana", "orange", "grape");
unset($fruits[2]); // 删除数组中索引为2的项,即"orange"
print_r($fruits); // 输出:Array ( [0] => apple [1] => banana [3] => grape )
?>
In the example above, we used the unset() function to remove the item “orange” at index 2 in the array $fruits. Finally, we printed the contents of the array using the print_r() function, and we can see that “orange” has been deleted.