470,612 Members | 2,233 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,612 developers. It's quick & easy.

How to substitute a character for another one


I want to substitute a character (e.g. 'R') for another one ('-R')
within a
word: 'RECORD' ---> '-RECO-RD'

Is it possible by using any PHP command? Regards.

Jul 17 '05 #1
1 5025

$i = "record";

$x = str_replace("r", "-r", $i); // looks through i for r's, replaces
them with -r's

echo $x;


that should work.

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Alex | last post: by
5 posts views Thread by Gary McCullough | last post: by
14 posts views Thread by Glen Able | last post: by
17 posts views Thread by =?Utf-8?B?R2Vvcmdl?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.