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

王林
Release: 2023-03-03 07:00:01
Original
5749 people have browsed it

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 $... ])
Copy after login

For example, if we want to destroy a single array element, the specific code is:

unset ($bar['quux']);
Copy after login

Code implementation:

<?php
$data=array (“0”=>1,“1”=>1,“2”=>1);
unset($data[0]);	
print_r($data);    
array (“1”=>1,“2”=>1);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template