Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
$data = [
'site1' => ['1','2','3','4'],
'site2' => ['2','3','4','5']
];
$matrix = [];
$i = 0;
foreach ( $data as $key => $row ) {
$j = 0;
$matrix[$j][$i] = $key;
$j++;
foreach ( $row as $item ) {
$matrix[$j][$i] = $item;
$j++;
}
$i++;
}
print_r($matrix);
foreach ( $matrix as $row ) {
foreach ( $row as $column ) {
echo $column, "\t";
}
echo "\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.