I have a variable with the following value:
1,2,11,17,2
I need to convert it to:
SER1, SER2, SER11, SER17, SER2
In other words I need to pad to the left of each number the words SER
How to accomplish this with PHP?
I have a variable with the following value: 1,2,11,17,2 I need to convert it
Share
You could use a regular expression to replace each number with SER prepended to the number:
preg_replace('/(\d+)/', 'SER$1', '1,2,11,17,2');