如何在Laravel中使用str_replace

问题描述:

如何在laravel框架中使用php函数str_replace.

我在表列名称上的数组键名,因此键具有"_",例如first_name,last_name等.我想在刀片文件中删除这些"_".我的要求是.blade.php文件中的字符串替换.

My array key names on table columns name so keys have '_' like first_name, last_name etc. i want to remove these '_' in blade file. my requirement is string replace in .blade.php file.

我正在尝试此php代码,但它没有用.

i am trying this php code but it's useless.

<th>{{str_replace('_', ' ', $str)}}</th>

谢谢

您可以在.blade.php文件中使用php代码

You can use php code in .blade.php file

尝试这样

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