Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert array to string with double quotes in php

Tags:

php

I have following array

$type=Array(
[0] => PL
[1] => LWP
[2] => Carry Forward
[3] => SL
);

I want to convert it into String.I used implode function to convert it.

$newarray=implode(",", $type);

but it reurn string like below

PL,LWP,Carry Forward,SL

I want String like below

("PL","LWP","Carry Forward","SL")

Please help me...

like image 729
piyush Avatar asked Jan 24 '26 16:01

piyush


1 Answers

Try this one ;)

$newarray='("'.implode('","', $type).'")';
like image 174
Wouter de Winter Avatar answered Jan 27 '26 06:01

Wouter de Winter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!