Home  >  Article  >  Backend Development  >  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
WBOYOriginal
2016-07-13 10:06:221376browse

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;>

The output results are as follows:

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

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...
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