Syntax for PHP array_shift() Function.
array_shift(array)
Parameter Description
array Specifies an input array
Example(1)
<?php
$array=array(0=>"Bike 1",1=>"Bike 2",2=>"Bike 3");
echo array_shift($array);
print_r ($array);
?>
In above example we created array and we shifted first element in array by using array_shift() Function.
Complete code for PHP array_shift() Function.
<!DOCTYPE html>
<html>
<head>
<title>PHP array_shift() Function with an example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<br>
<br>
<br>
<div class="text-center">
<h1>PHP array_shift() Function </h1>
</div>
<br>
<br>
<h2></h2>
<div class="well">
<?php
$array=array(0=>"Bike 1",1=>"Bike 2",2=>"Bike 3");
echo array_shift($array);
print_r ($array);
?>
</div>
<br>
</div>
</body>
</html>