right now I want to create a function to compare between two data statistics which is called as statisticsComparator
and it will accept 2 parameters which is the left_stat
and right_stat
.
Those key
s in both statistic data can be similar or have a slight differences.
This is what I already tried to make so far:
private static function statisticsComparator($left_stat, $right_stat)
{
foreach (self::STATS_DATABASE as $key => $field) {
$left_stat_field = json_decode($left_stat->$field, true);
$right_stat_field = json_decode($right_stat->$field, true);
$count_left_stat_field = count($left_stat_field);
$count_right_stat_field = count($right_stat_field);
// Choose
if ($count_left_stat_field <= $count_right_stat_field) {
foreach ($count_left_stat_field as $field) {
}
} else {
foreach ($count_right_stat_field as $field) {
}
}
}
}
and this is the example of the stats data:
I want to make this function as dynamically as possible, I'm using Laravel 5.8
Please help, thank you.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire