PHP code example of rikudou / array-merge-recursive
1. Go to this page and download the library: Download rikudou/array-merge-recursive library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rikudou / array-merge-recursive example snippets
$array1 = [
'test' => 'test'
];
$array2 = [
'test' => 'test2'
];
$result = array_merge_recursive($array1, $array2);
// $result =
// array(1) {
// 'test' =>
// array(2) {
// [0] =>
// string(4) "test"
// [1] =>
// string(5) "test2"
// }
// }
$array1 = [
'test' => 'test'
];
$array2 = [
'test' => 'test2'
];
$result = array_merge($array1, $array2);
// $result =
// array(1) {
// 'test' =>
// string(5) "test2"
// }
use function Rikudou\ArrayMergeRecursive\array_merge_recursive;
$array1 = [
'test' => 'test'
];
$array2 = [
'test' => 'test2'
];
$result = array_merge_recursive($array1, $array2);
// $result =
// array(1) {
// 'test' =>
// string(5) "test2"
// }
$array1 = [
'test' => [
'key1' => 'test',
'key2' => 'test',
'key3' => 'test'
]
];
$array2 = [
'test' => [
'key2' => 'test2',
'key4' => 'test2'
]
];
array(1) {
'test' =>
array(4) {
'key1' =>
string(4) "test"
'key2' =>
array(2) {
[0] =>
string(4) "test"
[1] =>
string(5) "test2"
}
'key3' =>
string(4) "test"
'key4' =>
string(5) "test2"
}
}
array(1) {
'test' =>
array(2) {
'key2' =>
string(5) "test2"
'key4' =>
string(5) "test2"
}
}