Search
 
SCRIPT & CODE EXAMPLE
 

PHP

PHP multidimensional array merge recursive

function array_merge_recursive_ex(array $array1, array $array2)
{
    $merged = $array1;

    foreach ($array2 as $key => & $value) {
        if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) {
            $merged[$key] = array_merge_recursive_ex($merged[$key], $value);
        } else if (is_numeric($key)) {
             if (!in_array($value, $merged)) {
                $merged[] = $value;
             }
        } else {
            $merged[$key] = $value;
        }
    }

    return $merged;
}
Comment

PREVIOUS NEXT
Code Example
Php :: php unset by value 
Php :: routing with php 
Php :: shortcode wordpress form 
Php :: laravel get route action 
Php :: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in 
Php :: check the existing image in s3 laravel 
Php :: get ids from object 
Php :: php custom error log 
Php :: php RFC3339 
Php :: laravel follow and unfollow relationship 
Php :: php object to json 
Php :: Laravel 7 pagination with search filter 
Php :: SIMPLE linked list in php 
Php :: php regex named groups 
Php :: php distinct 
Php :: laravel enable query log 
Php :: spatie/laravel-activitylog display only changed data 
Php :: array_search function in php 
Php :: laravel project composer [ErrorException] Undefined index: name 
Php :: php match expression 
Php :: php pre 
Php :: laravel validation rule 
Php :: xampp downgrade php 
Php :: how to develop package beside laravel project 
Php :: upload image in laravel 8 store in database and folder 
Php :: WooCommerce shop loop random array function not same values after each other 
Php :: download file from s3 using laravel 
Php :: php remove utf non breaking space 
Php :: php file handling 
Php :: Include Or Require Multiple Files On 1 Line 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =