I'm developing an application in PHP that needs to display a graphical indicator. The problem is that the data comes from an external API and depending on the filter applied, the API does not return points I need to insert into the chart.
Example:
// Chama a API sem filtros
$dados = $api->get()->limit(6);
var_dump($dados);
// Retorna
'metaPontual' =>
array (size=6)
3 => float 178036332.62
4 => float 176975684.39
5 => float 173823421.06
6 => float 170114093.13
7 => float 168775993.4
8 => float 167259382.68
// Aplicando um filtro
$dadosFiltrado = $api->get(['nome' => 'Lucas'])->limit(6);
var_dump($dadosFiltrado);
// O Array Não retorna todos os pontos.
'metaPontual' =>
array (size=6)
1 => float 183635670.39
4 => float 176975684.39
5 => float 173823421.06
6 => float 170114093.13
8 => float 167259382.68
9 => float 167259382.68
I need a routine that acts to create a "LEFT JOIN" between array 1 and array 2, remembering that the arrays are examples, the keys returned by the arrays are different, so that:
$arrayFinal = array_left_join(array_keys($dados), $dadosFiltrado);
var_dump($array_final)
'metaPontual' =>
array (size=6)
3 => null
4 => float 176975684.39
5 => float 173823421.06
6 => float 170114093.13
7 => null
8 => float 167259382.68