moses toh moses toh - 1 year ago 107
PHP Question

How to add single quotes in string php?

I have

$a = 6,9,13,1

I want to change to
$a = '6','9','13','1'

Any solution to solve my problem?

Answer Source

If $a is a string and you want to change numbers that way, you can use this code:

$a = preg_replace("/\d+/", "'$0'", $a);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download