Home > Backend Development > PHP Tutorial > PHP uses unset() to delete a certain unit (key) in an array, unset array_PHP tutorial

PHP uses unset() to delete a certain unit (key) in an array, unset array_PHP tutorial

WBOY
Release: 2016-07-13 10:06:22
Original
1409 people have browsed it

php uses unset() to delete a certain unit (key) in the array, unset array

The example in this article describes how PHP uses unset() to delete a certain unit (key) in an array. Share it with everyone for your reference. The specific analysis is as follows:

unset can delete either a variable or a unit in an array. But be aware that the array will not be reindexed.

Examples are as follows:

<&#63;php
$arr = array("朝阳区","海淀区","西城区","东城区","丰台区");
unset($arr[3]);
echo "<pre class="brush:php;toolbar:false">";
print_r($arr);
&#63;>
Copy after login

The output results are as follows:

Array
(
  [0] => 朝阳区
  [1] => 海淀区
  [2] => 西城区
  [4] => 丰台区
)
Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/959113.htmlTechArticlephp uses unset() to delete a certain unit (key) in the array. The unset array example in this article tells about php Use unset() to delete a cell (key) in an array. Share it with everyone...
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