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:
<?php $arr = array("朝阳区","海淀区","西城区","东城区","丰台区"); unset($arr[3]); echo "<pre class="brush:php;toolbar:false">"; print_r($arr); ?>
The output results are as follows:
Array ( [0] => 朝阳区 [1] => 海淀区 [2] => 西城区 [4] => 丰台区 )
I hope this article will be helpful to everyone’s PHP programming design.