String append in for each loop on laravel - development

String append in for each loop on laravel

I’m using a for each loop and fetching the value into the variable crosslisted_courses and also appending the next values in the loop into it, but the value does not gets appended!! The variable only stores the last fetched value

Have used .= to append the string !!

@foreach($fmfacactinss as $fmfacactins_slave)                                                                                                                                              

@if(($fmfacactins_slave->xlist_ctrl_crn == $master_crn) && ($fmfacactins_slave->crn <> $master_crn) ) 
@php  
$crosslisted_courses = '';                                                                                
$slave_crn=$fmfacactins_slave->crn;                                                                                
$crosslisted_courses .= $fmfacactins_slave->crs_subj_cd . ' ' . 
$fmfacactins_slave->crs_nbr . ' ' . $fmfacactins_slave->sect_nbr . ' ';                                                                                
echo($crosslisted_courses);                                                                                
@endphp
@endforeach



from Laravel Questions and Answers https://laravelquestions.com/php/string-append-in-for-each-loop-on-laravel/
via Lzo Media

Comments

Popular posts from this blog

ng-include of inline SVG does not display gradient except in Chrome

Using PHP and MySQL data to generate PDF letters like in MS Word mailmerge functionality - development

ng-show doesn’t work correct with value boolean