Concept Of array_combine() Function In PHP In My Own Explanation With An Example "Take 4 Arrays Then Margin The Arrays Using array_combine() Function"

Concept Of array_combine() Function In PHP In My Own Explanation With An Example "Take 4 Arrays Then Margin The Arrays Using array_combine() Function"

So, here today I am going to explain about the concept of array_combine() function with an example.

       But before starting with an explanation of array_combine() function, I like to mention that here I need to perform array_merge() function before and then only I can perform array_combine() function. Why is't so?, that I will explain while I will be explaining about array_combine() function below.

                              So, without wasting time just let's begin with my explanation of array_combine() function.

array_combine() function - array_combine() function is the function which merge two arrays into a single array. array_combine() function is the function which should have the same number of elements and same size array. array_combine() functions cannot merge more than two arrays at a time, and each array should be of same size in case of array_combine() function. To merge more than two arrays, I need to use array_merge() function which can merge more than two arrays like it can be three/four/five and so on... and array_merge() function can also be of different size. 

CODE OF array_combine() FUNCTION =>

<?php

$arr1=["Parnashri","Sayanti","Ayan"];

$arr2=["Anish","Debanjan","Gargi"];

$arr3=["Satindra","Abhishek","Srestra"];

$arr4=["Bhaskar","Suman","Debajyoti"];

$arrmer1=array_merge($arr1,$arr2);//It merge the first two arrays $arr1 and $arr2 using array_merge() function

print_r($arrmer1);

echo "<br>";

$arrmer2=array_merge($arr3, $arr4);//It merge the first two arrays $arr3 and $arr4 using array_merge() function

print_r($arrmer2);

echo "<br>";

$arrcom=array_combine($arrmer1, $arrmer2);//It merges or rather I can say it combines the two merged arrays $arrmer1 and $arrmer1 using array_combine() function

print_r($arrcom);

?>

OUTPUT OF THE CODE OF array_combine() FUNCTION =>

Array ( [0] => Parnashri [1] => Sayanti [2] => Ayan [3] => Anish [4] => Debanjan [5] => Gargi )
Array ( [0] => Satindra [1] => Abhishek [2] => Srestra [3] => Bhaskar [4] => Suman [5] => Debajyoti )
Array ( [Parnashri] => Satindra [Sayanti] => Abhishek [Ayan] => Srestra [Anish] => Bhaskar [Debanjan] => Suman [Gargi] => Debajyoti )

"Array ( [0] => Parnashri [1] => Sayanti [2] => Ayan [3] => Anish [4] => Debanjan [5] => Gargi )"  = Output of $arrmer1.

"Array ( [0] => Satindra [1] => Abhishek [2] => Srestra [3] => Bhaskar [4] => Suman [5] => Debajyoti )" = Output of $arrmer2.

"Array ( [Parnashri] => Satindra [Sayanti] => Abhishek [Ayan] => Srestra [Anish] => Bhaskar [Debanjan] => Suman [Gargi] => Debajyoti )" = Output of $arrcom.




  

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