Jump to content

converting character in a string to other characters


essjay_d12

Recommended Posts

[!--quoteo(post=358988:date=Mar 27 2006, 02:05 PM:name=Essjay_d12)--][div class=\'quotetop\']QUOTE(Essjay_d12 @ Mar 27 2006, 02:05 PM) [snapback]358988[/snapback][/div][div class=\'quotemain\'][!--quotec--]
i need to directly change a string $string to $string2

but whenever there is a , in $string it needs to change it to a % in $string2

thanks

d
[/quote]

you could try:
[code]$string2 = eregi_replace( ",", "%", $string1);[/code]
Why not use the [a href=\"http://www.php.net/str_replace\" target=\"_blank\"]str_replace[/a]() function, since it doesn't have the overhead of using regular expressions.
[code]<?php $string2 = str_replace( ',', '%', $string1); ?>[/code]

Ken

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.