lundi 10 mai 2021

Sum Values in a foreach loop in laravel controller

How to sum data After getting the previous calculations on controller Laravel

private $nn;

public function detailproject($code_project)
{
    $countdata = count($listdata);
    $countdata = 15 / $countdata;

    foreach ($listdata as $obj ) {
        $this->nn = $obj->percent * $countdata / 100;
        $this->nn +=($obj->persen);
    }
    
    dd($this->nn);
}

How to do this?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3hgFRoB
via IFTTT

Aucun commentaire:

Enregistrer un commentaire