php method to delete the specified value in the array: first use the array_search() function to find the specified value in the array, if not found, return false; then use the unset() function to destroy the specified array element.
# The unset() function is used to destroy the given variable.
(Recommended tutorial: php graphic tutorial)
Syntax:
void unset(mixed $var [, mixed $... ])
array_search() function searches for a key value in the array. If the specified key value is found in the array, the corresponding key name is returned, otherwise FALSE is returned. If a key value is found more than once in the array, the key name matching the first found key value is returned.
Grammar:
array_search(value,array,strict)
(Video tutorial recommendation: php video tutorial)
Implementation code:
Use array_search () and unset() functions delete specific values in the array
if(($key = array_search('day',$arr))){ unset($arr[$key]); }
The above is the detailed content of How to delete specified value in array in php. For more information, please follow other related articles on the PHP Chinese website!