How to delete an element from an array in PHP?

I need to know how to delete an element in an array. I tried making it null but was not successful.

Comments

  • <?php
    $x = array(1, 2);
    unset($x[0]);
    var_dump($x);
    ?>

    array(1) {
      [1]=>
      int(2)
    }

    (index remains unchanged.)
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion