saurabh  singh
How to delete an element from an array in php?
By saurabh singh in PHP on Mar 18 2015
  • Roshan Rathod
    Jul, 2020 19

    Using unset() function
    Here is a example:
    $array = [0 => "a", 1 => "b", 2 => "c"]; unset($array[1]);//↑ Key which you want to delete

    ?>

    • 0
  • Anant Singh
    Apr, 2019 11

    You have to use unset and reinitialize same array

    • 0
  • Munesh Sharma
    May, 2016 31

    http://stackoverflow.com/questions/369602/delete-an-element-from-an-array

    • 0
  • saurabh  singh
    Mar, 2015 18

    $anArray = array("X", "Y", "Z");unset($anArray[0]);//'dumps' the content of $anArray to the page: var_dump($anArray); The output of the var_dump function will be:array(2) { [1]=> string(1) "Y" [2]=> string(1) "Z" }

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS