array keys multidimensional php code example

Example 1: php implode multidimensional array

$users = [
	'users' => ['[email protected]','[email protected]'],
	'admins' => ['[email protected]', '[email protected]']
];

// function to convert array of arrays to string
function implodeArrayofArrays($array, $glue  = ', ') {
        $output = '';
        foreach ($array as $subarray) {
            $output .= implode($separator, $subarray);
        }
        return $output;
}

echo implodeArrayofArrays($users);

// "[email protected], [email protected], [email protected], [email protected]"

Example 2: php take out 2 level array key value

foreach($bigArray as $array){    
    foreach($array as $key=>$value){
        echo $key;
    }
}


#If if helps you give it Thumbs up

Tags:

Php Example