#42. PHP Array_shift & Array_unshift

PHP Array_shift :


Run Code:

<?php

$fruit = ['Apple', 'Banana', 'Mango', 'Orenge'];

// Using for Arr shift remove 1st value
array_shift($fruit);


echo "<pre>";
print_r($fruit);
echo "</pre>";
?>

Array Unshift:



Run Code:

<?php

$fruit = ['Apple', 'Banana', 'Mango', 'Orenge'];

// Using for Arr Unshift add 1st value
array_unshift($fruit, "Grapes");
echo "<pre>";
print_r($fruit);
echo "</pre>";
?>

Comments

Popular posts from this blog

#30. PHP Recursive Function