Home >Backend Development >PHP Problem >How to delete the specified key value in the array in php
The method for PHP to delete the specified key value in the array is: [unset(array name[key name]);]. The unset() function is used to destroy a given variable. For example, if we want to destroy a single array element, the specific code is as follows: [unset ($bar['quux']);].
Function introduction:
(Recommended tutorial: php tutorial)
unset() function Used to destroy the given variable.
Syntax:
void unset ( mixed $var [, mixed $... ])
For example, if we want to destroy a single array element, the specific code is:
unset ($bar['quux']);
Code implementation:
<?php $data=array (“0”=>1,“1”=>1,“2”=>1); unset($data[0]); print_r($data); array (“1”=>1,“2”=>1);
The above is the detailed content of How to delete the specified key value in the array in php. For more information, please follow other related articles on the PHP Chinese website!