Wednesday, May 9, 2018

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

No comments:

Post a Comment