Reputation: 139
Hi developers I have problem I don't know what type of implode is this, I want to achieve is in every data has a double quotation mark. Ex. "1600","1793","3211" However in my output i look like "1600,1608" so in my sql the query is wrong. so is it possible to make my data look like this "1600","1608" ?
I will show you guys my sample code:
$selected_store = $request->get('selected_store');
$converted_selected_store = '"'.implode('","',(array)$selected_store).'"';
dd($converted_selected_store);
My Output:
My Goal:
"1600","1608"
Upvotes: 1
Views: 1354
Reputation: 92
You can also try
implode(array_map(function($x) { return '"' . $x . '"';}, $selected_store), ',');
Upvotes: 0
Reputation: 5316
Obviously your $selected_store
is a simple string, so it's quite enough to apply str_replace()
, like:
$converted_selected_store = '"'.str_replace(',','","',$selected_store).'"';
Upvotes: 1