如何实现每个数据在laravel(Implode)中都有双引号

开发人员我有问题,我不知道这是什么类型的内爆,我想实现的是在每个数据中都有一个双引号。例如“1600”,“1793”,“3211”但是在我的输出中,我看起来像“1600,1608”,所以在我的sql中查询是错误的。那么有可能让我的数据看起来像这个“1600”,“1608”吗?


我将向你们展示我的示例代码:


$selected_store = $request->get('selected_store');

$converted_selected_store = '"'.implode('","',(array)$selected_store).'"';


dd($converted_selected_store);

我的输出:

http://img2.mukewang.com/62feef5d0001fb3b03720115.jpg

我的目标:

"1600","1608"


杨魅力
浏览 105回答 2
2回答

撒科打诨

显然,你的是一个简单的字符串,所以它足以应用,比如:$selected_storestr_replace()$converted_selected_store = '"'.str_replace(',','","',$selected_store).'"';

牛魔王的故事

您也可以尝试implode(array_map(function($x) { return '"' . $x . '"';}, $selected_store), ',');
打开App,查看更多内容
随时随地看视频慕课网APP