Home  >  Article  >  Backend Development  >  How to delete the specified key value in the array in php

How to delete the specified key value in the array in php

王林
王林Original
2020-07-23 14:33:015748browse

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']);].

How to delete the specified key value in the array in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn