Dinesh G
Dinesh G

Reputation: 11

How implode array elements in php?

How implode array element into single string in php

$name = array( 'id', "no", "date",'fadd');
echo  implode("','",$name);

I am looking for the output is

'id', 'no', 'date', 'fadd'

Upvotes: 0

Views: 165

Answers (1)

Alex Howansky
Alex Howansky

Reputation: 53563

You've got the implode part right, just explicitly echo a quote before and after to get the leading and trailing characters:

$name = array( 'id', "no", "date",'fadd');
echo  "'" . implode("','",$name) . "'";

Upvotes: 1

Related Questions