Assuming that both arrays have the same number of elements you have to create a way to iterate those arrays and use the iteration index to use data from each one.
If you use the array_map
you don’t even need to know the iteration index and you can mix the two directly like this:
function misturar($nome, $perc){
return $nome.' - '.$perc.'%';
}
$c = array_map("misturar", $corretor, $comissao);
echo implode($c, ' | ');
Although in this case you find it simpler with array_map, you can also do so:
$res = '';
for ($i = 0; $i < count($corretor); $i++){
$res.= $corretor[$i].' - '.$comissao[$i].'% | ';
}
echo substr($res, 0, -3);
Example: https://ideone.com/TyoYzm
You just want to merge the result to display, or you want to create a new array with the data in "merge"?
– user28595
http://answall.com/questions/27631/mesclar-arrays-em-php
– Diego
@Diegof thanks for helping, Sergio’s response was exactly what I needed.
– Igor Silva