Welcome Guest, Not a member yet? Register   Sign In
How to merge /append arrays?
#1

[eluser]umbongo[/eluser]
if i have array1('abc','def','ghi') and array 2 ('jkl','mno') how can i merge/ append them to get array3('abc','def','ghi','jkl','mno') ???
#2

[eluser]Lurius[/eluser]
[quote author="umbongo" date="1291004846"]if i have array1('abc','def','ghi') and array 2 ('jkl','mno') how can i merge/ append them to get array3('abc','def','ghi','jkl','mno') ???[/quote]

array_merge
#3

[eluser]Unknown[/eluser]
you can use the php function array_merge like this:
Code:
$array1 = array('abc','def','ghi');
$array2 = array('jkl','mno');
$result = array_merge($array1, $array2);
print_r($result);

It you print:
Code:
array ( 'abc','def','ghi', 'jkl','mno')
#4

[eluser]umbongo[/eluser]
Thanks guys
#5

[eluser]skunkbad[/eluser]
The php documentation at php.net is your friend. There are many array functions in php, and in many cases you can find a function that will do exactly what you want it to do. Other times you have to get creative and make your own functions.
#6

[eluser]zhangshjin[/eluser]
There are many array functions in php, and in many cases you can find a function that will do exactly what you want it to do.




Theme © iAndrew 2016 - Forum software by © MyBB