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 =>


Q2. What is meant by array_unshift()?

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 =>


Coding Example : 03 =>

<?php
$arr=["Parnashri","Sayanti","Ayan","Anish","Debanjan"];
$arrunshift=array_unshift($arr, "Gargi","Satindra");
print_r($arr);
?>

Output Of Coding Example : 03 =>





Comments

Popular posts from this blog

Programmings Based On Array And String Functions To Merge The 2 Arrays, Then After Merge Convert Into String And Then Find Out The 1st And Last Word From The Reverse String

PHP WEB DEVELOPMENT INTERVIEW QUESTIONS ASKED IN APOLLO HOSPITAL ALONG WITH MY OWN CONCEPTS AND MY OWN EXPLANATION ANSWERS(PART - 1) REST OF THE QUESTIONS AND ANSWERS WILL BE PREPARED BY ME IN MY NEXT BLOG

Mini Project On Multi User CRUD Operations(Create, Read, Update & Delete) Of Donar Details Of Indian Nationals Who Donate To Ramkrishna Math, Belur Math Using PDO (PHP Data Objects) With Proper Explanation Of Each And Every Individual Line Of The Code Of connection.php Page, form.php Page, formaction.php Page, admin_display.php Page, client_display.php Page, edit.php Page, editaction.php Page And delet.php Page (Here You Will Find The Image Of Sayang Sri Ramkrishna Dev, Sayang Sri Ma Sarada Devi & Sayang Sri Swami Vivekananda) In My CRUD Operation