I have this string:
$mystring = "SIZE,DETAIL";
And I´m using:
@if (strpos($mystring, 'SIZE'))
{{ $item->size }}
@endif
@if (strpos($mystring, 'DETAIL'))
{{ $item->detail }}
@endif
But this works fine with SIZE, but not with DETAIL.
What is the problem here?
Since you're using Laravel, you can use str_contains()
helper:
@if (str_contains($mystring, 'SIZE'))
The
str_contains
function determines if the given string contains the given value
This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE.
Try this:
@if (strpos($mystring, 'SIZE') !== false)
{{ $item->size }}
@endif
@if (strpos($mystring, 'DETAIL') !== false)
{{ $item->detail }}
@endif
refer: http://php.net/manual/en/function.strpos.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With