Answers for "php get first element of array without removing it"

PHP
5

how to remove first element in array php

<?php
$stack = array("orange", "banana", "apple", "raspberry");
$fruit = array_shift($stack);
print_r($stack);
?>


// Array
// (
//     [0] => banana
//     [1] => apple
//     [2] => raspberry
// )
Posted by: Guest on March-27-2020
1

remove first element in array php

$arr = [1,2,3,4];
array_shift($arr);
print_r($arr); // [2,3,4]
Posted by: Guest on July-27-2020
1

first item in array php

$firstItem = array_shift($array);
Posted by: Guest on May-24-2020

Code answers related to "php get first element of array without removing it"

Browse Popular Code Answers by Language