<?php
$array = [
["firstname" => "John", "lastname" => "", "email" => "", "uri" => ""],
["firstname" => "", "lastname" => "Smith", "email" => "", "uri" => ""],
["firstname" => "", "lastname" => "", "email" => "john@example.org", "uri" => ""]
];
$result = array_shift($array); // remove the first row and push it into the result array
foreach ($array as $row) {
foreach ($row as $key => $value) {
if ($value !== '') {
$result[$key] = $value; // only overwrite where a non-empty value exists
}
}
}
var_export($result);
preferences:
24.94 ms | 405 KiB | 5 Q