PHP array_shift() functionThe array_shift() function is an inbuilt function of PHP. The array_shift( ) function is used to remove the first element from an array, and returns the value of the removed element. This function was introduced in PHP 4.0. SyntaxParameter
Return typeThe array_shift( ) function returns the value of the removed element from an array. If the array is empty, it will return NULL. Important note: If the keys are numeric, all elements will get new keys, starting from 0 and increases by 1.Example 1Output: testArray ( [0] => one day [1] => t20 ) Example 2Output: Array ( [0] => math [1] =>english [2] =>hindi ) Science Example 3Output: 200Array ( [sehwag] => 400 [ganguly] => 500 [yuvraj] => 100 ) Example 4Output: TCSArray ( [0] => Infosys [1] =>Mindtree )
Next TopicPHP Array Functions
|