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?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire