As commented, you can do this only with the functions array_map
and explode
, still with the array_filter
to remove possible unwanted results:
function relacao_tipo_metragem($tipo, $metragem) {
if ($tipo and $metragem) {
return "{$tipo}: {$metragem}";
}
return null;
}
$tipo = explode(',', 'a,b,c,d');
$metragem = explode(',', '15,18,32,44');
$dados = array_filter(array_map('relacao_tipo_metragem', $tipo, $metragem));
print_r($dados);
Generating the result:
Array
(
[0] => a: 15
[1] => b: 18
[2] => c: 32
[3] => d: 44
)
If one of the values, either type or length, is not set, the column will be ignored.
You can use the
explode
. Documentation and work on it. How it will generatearrays
, is interesting this topic: Merge all values at the same array level, at the same level– rbz