jeudi 29 novembre 2018

Lavarel PHP for loops and if statements

Currently trying to build a for loop to read through my $userSkills array and then using an if statement to print out specific text based on it.

This is how the code looks like

@for ($x = 1; $x < $skillCount; $x++) {
    @if($userSkills[$x] = '{ 66; }')
        <span>Hi</span>
    @else
        <span></span>
    @endif                        
}
@endfor

And in my array it would be {AA, 66, 67, 69} So I wanted to make it print out as such

Hi 67 69

However the output looks like this

{ Hi } { Hi } { Hi } 

Aucun commentaire:

Enregistrer un commentaire