I have a problem, I am currently trying to compare two objects, one object is cash sales and the other is card sales.
Cash sales
[
{
"ventas": 1,
"dia": 7,
"total": 120
},
{
"ventas": 1,
"dia": 8,
"total": 100
}
]
Sales with card
[
{
"ventas": 3,
"dia": 8,
"total": 360
}
]
But for daily reports using ChartJs I try to get this structure:
Cash sales
[1, 1]
Sales with card
[0, 3]
For that I try to perform with a foreach
foreach ($ventasEfectivo as $keyEfecitvo => $efectivo) {
$contado[] = $efectivo->ventas;
foreach ($ventasTarjeta as $keyCredito => $credito) {
if ($keyEfecitvo == $keyCredito) {
$credito[] = $credito->ventas;
}elseif(isset($keyCredito)){
$credito[] = 0;
}
}
}
But this brings me back:
[3,0]
Instead of
[0, 3]