I have the following array
01 03 02 15
05 04 06 10
07 09 08 11
12 14 13 16
I want to convert a string like the following:
$input = array(
array('01', '02', '03', '04'),
array('11', '12', '13', '14'),
array('21', '22', '23', '24'),
array('31', '32', '33', '34'),
);
$newArray = array();
foreach($input as $rowIndex => $row) {
foreach($row as $key => $val) {
if(!$newArray[$key]) {
$newArray[$key] = array();
}
$newArray[$key][$rowIndex] = $val;
}
}
$strRows = array();
foreach($newArray as $key => $row) {
$strRows[$key] = join(',', $row);
}
$output = join('|', $strRows);