如何按,
拆分字符串,但跳过其中一个数组中的,
?
字符串 - "'==', ['abc', 'xyz'], 1"
当我执行explode(',', $expression)
时,它会在数组中给出4项。
array:4 [
0 => "'=='"
1 => "['abc'"
2 => "'xyz']"
3 => 1
]
但我希望我的输出是 -
array:3 [
0 => "'=='"
1 => "['abc', 'xyz']"
2 => 1
]
Blade :: directive('role',function($ symbol,$ check_roles){ .....}
时,我收到此错误消息 错误:Type error: Too few arguments to function App\Providers\RoleServiceProvider::App\Providers\{closure}(), 1 passed and exactly 2 expected
在我的视图中:@role('==', ['Manager', 'User'])
。结果,laravel将所有参数转换为字符串。所以现在我必须这样解析。 - Amitoz Deol