I have some string like this
Name xxx Product 1 Pc 100
Name Pci Product2Pc.200
Name Pcx Product 3 Pcs300
I want to turn PC
to Price
And this is result that I want
Name xxx Product 1 Price 100
Name Pci Product 2 Price 200
Name Pcx Product 3 Price 300
At first I use
$pattern = array('/(\s*)Product(\s*)/', '/(\s*)(Pc\.?|Pcs)(\s*)/');
But it came to change all of my PC to Price
Name xxx Product 1 Price 100
Name Price i Product 2 Price 200
Name Price x Product 3 Price 300
This is my code now.
$pattern = array('/(\s*)Product(\s*)/', '/[^a-z](Pc\.?|Pcs)[^a-z]/');
$replacement = array(' Product ', ' Price ');
$title = preg_replace($pattern, $replacement, $title, -1);
But it result like this
Name xxx Product 1 Price 100
Name Pci Product Price 00
Name Pcx Product 3 Price 00
Thanks you.