Search
 
SCRIPT & CODE EXAMPLE
 

PHP

array flat php

$c = ["a" => ["x" => "X", "y" => "Y"], "b" => ["p" => "P", "q" => "Q"]];
print_r(array_merge(...array_values($c)));

Array
(
    [x] => X
    [y] => Y
    [p] => P
    [q] => Q
)
Comment

array_flatten php

/**
 * Function converts multidimentional array to a plain one
 *
 * @param $arr multidimensional array
 *
 * @return array
 */
function array_flatten($arr) {
    $return = [];
    foreach ($arr as $key => $value) {
        if (is_array($value)) {
            $return = array_merge($return, array_flatten($value));
        } else {
            $return[] = $value;
        }
    }
    return $return;
}
Comment

php flatten array

array_merge(...$a);
Comment

flatten in array php

array_merge(...$a);
Comment

flatten in array php

array_merge([], ...$a);
Comment

array flat php

$a = [[10, 20], [30, 40]];
$b = [["x" => "X", "y" => "Y"], ["p" => "P", "q" => "Q"]];

print_r(array_merge(...$a));
print_r(array_merge(...$b));

Array
(
    [0] => 10
    [1] => 20
    [2] => 30
    [3] => 40
)
Array
(
    [x] => X
    [y] => Y
    [p] => P
    [q] => Q
)
Comment

PREVIOUS NEXT
Code Example
Php :: laravel collection to array 
Php :: which programming languae does php resemble to? 
Php :: How to Auto Backup Mysql Database Using PHP Script 
Php :: Laravel - Add conditional where clause in query 
Php :: php convert string to array 
Php :: how to get length array in php 
Php :: change or set post type wordpress 
Php :: php check if day in month 
Php :: the requested url was not found on this server. apache/2.4.46 (win64) openssl/1.1.1h php/8.0.1 server at localhost port 80 
Php :: laravel collection methods 
Php :: disadvantages of php 
Php :: sanctum 
Php :: ajax load more button wordpress 
Php :: php into javascript 
Php :: laravel validate change password 
Php :: SUM with Eloquent 
Php :: -regular_price 
Php :: laravel migration longtext length 
Php :: loginByUserID in conrete 
Php :: php order array 
Php :: php return associative array 
Php :: how to get favicon with Goutte php 
Php :: php extend class 
Php :: nginx php-fpm 
Php :: laravel pest assertstatus 
Php :: get custom field post wordpress dev 
Php :: what is carriage return in php 
Php :: php configuration file location in centos 8 
Php :: find auth laravel 
Php :: Pure Intersection Types - PHP 8.1 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =