从laravel的句子中取一个词?


$text="Samsung Galaxy s21 ";
$product=  Product::Select('*')->where('name', 'like', "%{$text}%")->get();

如何从$product中得到Galaxy相关产品

$product= Product::where('name', 'like', '%' . $text . '%')->get();

$product= Product::where('name', 'like', "%$text%")->get();

你可以这样做。从这个帖子里得到的,larvel -5 'LIKE'等效(雄辩)

最新更新