How to use the in_array function in a Blade template in Laravel 4?

How can we use a function in_arrayin a Blade template in Laravel 4?

+4
source share
1 answer

You can use the function in_array, as usual, in a regular php file without using the blade template language. In your view, something.blade.phpyou can do something like:

<?php
    if (in_array($something, $an_array)) {
        echo "Yes";
    }
?>

If you want to use the function in_arrayinside the if statement, you can use the blade template syntax for the if statement, for example:

 @if (in_array($something, $an_array))
      <span>Something</div>
 @endif

in_array php- . in_array , , .

+11

All Articles