in this article, we will learn how to delete or unset array element from a specific position in PHP


Some steps you need to do

  • //lets create an array
  • //delete element from specific index
  • //retrieve all remaining elements

Example:

<?php


//lets create an array
$lang = array("laravel", "php", "jquery", "nodejs", "boostrap");

//delete element from 0 index
unset($lang[0]);

//retrieve all remaining elements
while (list ($key, $val) = each($lang)) {
    echo "$key -> $val <br>";
}
?>


Output:

1 -> php
2 -> jquery
3 -> nodejs
4 -> boostrap