ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

Sameeh Yousef
من قبل Sameeh Yousef , Senior Solution Architect , Ejada

array array_merge( array $array1[, array $...]]

- If the arrays have same string keys, the last value for that key will overwrite the previous one.

- If arrays contain numeric keys, the later value will not overwrite the original value, but will be appended.

Sample : 

<?php $ary1 = array(78, "name" => "Ahmed"); $ary2 = array(5"Salem""name" => "Khaled""Class" => "Grade9""School" => "Khaled ben Alwaleed"); $mergeResarray_merge($ary1$ary2); print_r($mergeRes); ?>

Output

Array (

[0] =>7

[1] =>8

[name] => Khaled     /* value “Ahmed” was overwritten by value “Khaled” because they have the same string keys “[name]” */

[2] =>5

[3] => Salem

[Class] => Grade9

[School] => Khaled ben Alwaleed

 

)

Parvez Ahmed
من قبل Parvez Ahmed , Frontend Developer (Angular) , GREEN DELTA INSURANCE COMPANY LIMITED

<?php

$a1=array("red","green");

$a2=array("blue","yellow");

$a3=array("blue","yellow");

print_r(array_merge($a1,$a2,$a3));

?>

Adel Ezat Fawzy Ellozy
من قبل Adel Ezat Fawzy Ellozy , Webdeveloper. , Saudi Arabian Maritiem Sports Federation

$result_array = array_merge(array1,array2,array3...) ;

Reference :

https://www.w3schools.com/php/func_array_merge.asp

 

Muhammad shahram Javed
من قبل Muhammad shahram Javed , Senior Software Developer , Makkah Techno Valley - Wadi Makkah

Simple and fast

array_merge($array1, $array2, array3, ..., $arrayn)

Ahmed Said
من قبل Ahmed Said , Senior Full Stack Engineer , Robusta Studio

array array_merge ( array $array1 [, array $... ] )

Merges the elements of one or more arrays together so that the values of one are appended to the end of the previous one. It returns the resulting array.

If the input arrays have the same string keys, then the later value for that key will overwrite the previous one. If, however, the arrays contain numeric keys, the later value will not overwrite the original value, but will be appended.

Values in the input array with numeric keys will be renumbered with incrementing keys starting from zero in the result array.

Mahedy Hasan
من قبل Mahedy Hasan , Technical Officer , eComclips

using array_merge function:array_merge(array1,array2,array3...) ;

taimoor ahmad
من قبل taimoor ahmad , Backend Developer , Inspire Uplift

you can use array_merge() to combine multiple arrays

ahmed tahar
من قبل ahmed tahar , warehouse guard , مؤسسة وثلاجة السهلي للمواد الغذائية

Three-dimensional array

<?php $students = array( array('Ali', 29, 'KSA'), array('Khaled', 30, 'KSA'), array('Mohammed', 35, 'KSA') ); echo $students[0][0] . " is " . $students[0][1] . " years old and from " . $students[0][2] . "<br>"; echo $students[1][0] . " is " . $students[1][1] . " years old and from " . $students[1][2] . "<br>"; echo $students[2][0] . " is " . $students[2][1] . " years old and from " . $students[2][2] . "<br>";

AHMED ِِِAL MOTG
من قبل AHMED ِِِAL MOTG , سكرتير لمبادرة ضمن برنامج 2030 لوزارة البيئة - الاشراف على اعمال الحاسب- مشرف التحرير والمراجعة , وزارة البيئة والمياه والزراعة

Using array_merge () function we can integrate two or more arrays into PHP using a array_merge function. This function accepts one or more arrays and returns a new array with all elements of the input array/arrays

mohammad abd almoneam mohammad alfke
من قبل mohammad abd almoneam mohammad alfke , مطور ويب , الانترنت

$arr1 = [1,2,3];

$arr2 = [4,5]

$allarr[]=$arr1;

$allarr[]=$arr2;

result 

$allarr[0] = [1,2,3]

$allarr[1]=[4,5]

المزيد من الأسئلة المماثلة