Home >Backend Development >PHP Problem >How to delete specified key name in array in php
In PHP, you can use the unset() function to delete the specified key name in the array, the syntax format is "unset(array name[key name]);". The unset() function can destroy a given variable, and its behavior will vary depending on the type of variable you want to destroy.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php deletes the array specified key name
In PHP, you can use the unset() function to delete the specified key name in the array. The syntax format is as follows:
unset(数组名称[键名]);
Example:
<?php $data=array ("0"=>1,"1"=>1,"2"=>1); unset($data[0]); print_r($data); ?>
Output:
Array ( [1] => 1 [2] => 1 )
PHP unset() function
unset() function is used to destroy the given variable.
Syntax
void unset ( mixed $var [, mixed $... ] )
Parameter description:
$var: variable to be destroyed.
Return value: No return value.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to delete specified key name in array in php. For more information, please follow other related articles on the PHP Chinese website!