1$colors = array(2=>"blue",3 =>"green",1=>"red");
2$firstValue = reset($colors); //blue
3$firstKey = key($colors); //2
1<?php
2$stack = array("orange", "banana", "apple", "raspberry");
3$fruit = array_shift($stack); //Remove "orange" from array and return it
4print_r($stack);
5/** OUTPUT:
6Array
7(
8 [0] => banana
9 [1] => apple
10 [2] => raspberry
11)
12*/
13?>
1For PHP version 7 and above
2
3$array = array(
4 "1" => "PHP code tester Sandbox Online",
5 "foo" => "bar",
6 "case" => "Random Stuff: " . rand(100,999),
7 "PHP Version" => phpversion()
8);
9
10$firstValue = reset($colors); // PHP code tester Sandbox Online
11$firstKey = key($colors); // 1