php array_values multidimensional code example
Example 1: php return array
<?php
function data() {
$out[0] = "abc";
$out[1] = "def";
$out[2] = "ghi";
return $out;
}
$data = data();
foreach($data as $items){
echo $items;
}
Example 2: php implode multidimensional array
$users = [
'users' => ['[email protected]','[email protected]'],
'admins' => ['[email protected]', '[email protected]']
];
function implodeArrayofArrays($array, $glue = ', ') {
$output = '';
foreach ($array as $subarray) {
$output .= implode($separator, $subarray);
}
return $output;
}
echo implodeArrayofArrays($users);