Home » Php » php – How to use str_replace and strtolower in Laravel blade

php – How to use str_replace and strtolower in Laravel blade

Posted by: admin February 25, 2020 Leave a comment

Questions:
<select name="fields[{{ $value }}]">
    @foreach (config('app.wc_fields') as $db_field)
    <option value="{{ (\Request::has('header')) ? $db_field : $loop->index }}" @if (str_replace(' ', '_', strtolower($value)) == $db_field) selected @endif > {{ $db_field }}</option>
    @endforeach
</select>

Here is what am trying.

How to&Answers:

You have multiple options:

<?=str_replace('_', ' ', $str)?>

{!! str_replace('_', ' ', $str) !!}

You can use trans() helper:

{{ strtolower(trans('options.terms')) }}