Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add Apostrophe in php native

Tags:

php

I have a following string

$data = "20150825131738_262,20150825132227_241,20150825132254_898,20150825132320_209";

How to add ' in $data. So the resultant output is as follows

'20150825131738_262','20150825132227_241','20150825132254_898','20150825132320_209,20150825132346_124','20150825132406_744','20150825143522_447','20150828145011_928'

help me thank's

like image 570
Maestro Vladimir Avatar asked Sep 09 '15 05:09

Maestro Vladimir


2 Answers

Following would give you the desired results

$data = "20150825131738_262,20150825132227_241,20150825132254_898,20150825132320_209";
$data_array = explode(',', $data);
$data = "'". implode("','", $data_array) . "'";
print_r($data);

See it running online here

like image 168
Mubashar Avatar answered Sep 28 '22 18:09

Mubashar


Try This

$arr=explode(',', $data);

implode("','",$arr);
like image 37
er.irfankhan11 Avatar answered Sep 28 '22 18:09

er.irfankhan11