Full Concepts On array_shift() And array_unshift() Function With 3 Coding Examples Each Prepared By Me Of Array Functions In PHP
Full Concepts On array_shift() And array_unshift() Function With 3 Coding Examples Each Prepared By Me Of Array Functions In PHP
Q1. What is meant by array_shift()?
Ans: array_shift() removes the first element of an array.
Coding Example : 01 =>
<?php
$arr=["Dog","Cat","Tiger"];
$arrshift=array_shift($arr);
print_r($arr);
?>
Output Of Coding Example : 01 =>
Coding Example : 02 =>
<?php
$arr=["3","4","8","16"];
$arrshift=array_shift($arr);
print_r($arr);
?>
Output Of Coding Example : 02 =>
Coding Example : 03 =>
<?php
$arr=["Ginny","Abhishek","Rohaan"];
$arrshift=array_shift($arr);
print_r($arr);
?>
Output Of Coding Example : 03 =>
Ans: array_unshift() function inserts elements at the beginning of an array.
Coding Example : 01 =>
<?php
$arr=["1","2","3","4","5"];
$arrunshift=array_unshift($arr, "0");
print_r($arr);
?>
Output Of Coding Example : 01 =>
Coding Example : 02 =>
<?php
$arr=["Parnashri","Sayanti","Ayan","Anish","Debanjan"];
$arrunshift=array_unshift($arr, "Gargi","Satindra");
print_r($arr);
?>
Output Of Coding Example : 02 =>
<?php
$arr=["Parnashri","Sayanti","Ayan","Anish","Debanjan"];
$arrunshift=array_unshift($arr, "Gargi","Satindra");
print_r($arr);
?>
Output Of Coding Example : 03 =>
Comments
Post a Comment