Oliver Spryn Oliver Spryn - 1 year ago 144
PHP Question

PHP Unset Array Value

I am working with a PHP loop, and I had one question regarding how unset affects the array keys. This array uses the standard numeric keys assigned by PHP,

0, 1, 2, 3 etc...
. Whenever
runs on an array value, are the array keys shuffled or are they maintained as before?

Thank you for your time.

Answer Source

The keys are not shuffled or renumbered. The unset() key is simply removed and the others remain.

$a = array(1,2,3,4,5);

    [0] => 1
    [1] => 2
    [3] => 4
    [4] => 5
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download