I have a problem. I want to replace certain strings only if they are exactly like I typed. So if there is a string with 5 Eur
he should only be replaced with e.g. Steam 5 Euro
, if he stands alone and not if the string is like How are you 5 Eur pls
.
With my actual code this is not possible... I use e.g.:
$string = str_replace('Apple Itunes 25 Euro Guthaben Prepaid De', 'Apple iTunes 25 Euro', $string)
Because here the string contains 25 Eur
this code is also adding some stuff:
$string = str_replace('25 Eur', 'Steam 25 Euro', $string);
But if I want to use preg_replace(/25 Eur/i)
I get this error:
PHP Warning: preg_replace(): Unknown modifier '?' in
So I have two questions:
How can I use an multibyte replace function?
How can I tell this function only to replace a certain string if he stands alone and not if he contains the searched string?
Greetings and Thank You!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…