Posted by Amit Tiwari
Hello friends !!! Here i am going to teach you about the ( PHP: array_merge) & (PHP: array_combine).
Hello friends !!! Here i am going to teach you about the ( PHP: array_merge) & (PHP: array_combine).
PHP: array_merge-
array_merge merges the elements of one or more than one array such that the value of one array appended at the end of first array. If the arrays have same strings key then the later value overrides the previous value for that key .
<?php
$array1 = array("course1" => "Amit","course2" => "Tiwari");
$array2 = array(("course1" => "Amit","course3" => "Makersofweb");
$result = array_merge($array1, $array2);
print_r($result);
?>
Output :
Array
(
[course1] => Amit
[course2] => Tiwari
[course3] => Makersofweb
)
PHP: array_combine-
<?php
$array1 = array("course1","course2");
$array2 = array(("Amit ","Tiwari");
$new_array = array_combine($array1, $array2);
print_r($new_array);
?>
Output :
Array
(
[course1] => Amit
[course2] => Tiwari
)
No comments:
Post a Comment