·: Site description :·
Welcome!

NetBulge.com provides code, scripts, tips & tricks and general information about web development aimed to help webmasters and web designers.

Instead of packing all the info we can get into a huge database, our goal is to produce a high quality compilation of code snippets and articles. Web developers will find in these pages a fresh and savvy view of most of the issues concerning programming and designing for the web; as well as a good site to visit regularly for help and inspiration.

Enjoy!
Zones
Navigation
Search

Sessions

NetBulge.com RSS2 feed



About Hosting:

I use and recommend Hostgator for all my hosting needs. It is the only company I have tried (and I have tried plenty) that hasn't given me a headache and responds quickly and fairly to everything I ever need. I run 3 accounts that host over 20 sites with Hostgator and I am happy recommending it to all my family, friends and clients. If you are looking for a cheap yet solid host, IMO Hostgator is the way to go. I do get a comission if you register through the link, but even if you don't like me and don't want me to get a comission, go to Hostgator for your hosting needs and save yourself plenty of cash and headaches.


 Print version Send article via e-mail  

Replacing letters and words


web zone resourcesThe strtr PHP function can be easily used to replace all the occurrences of letters in a string for other letters, and it can also receive a list (array) of replacement words; doing all the necessary changes in one clean sweep.


When all you need to replace is letters, the strtr function receives 3 arguments: The original string, the letters to find and the replacements:

$raw_string="Text with áccénts";
echo strtr($raw_string, "áé", "ae");

 

But when replacing words, you can quickly setup and array and use only two arguments in the function call:

$swap_list = array("%ftcolor%" => "dark gray", "%bgcolor%" => "white");
echo strtr("The font color is %ftcolor%, and the background is %bgcolor%", $swap_list);

 

Here is a useful example; code for replacing tabs and line jumps with HTML equivalents:

$swap_list = array("\t" => "&nbsp;&nbsp;&nbsp;&nbsp;", "\n" => "<br>");
echo strtr("\tSample input\n like you could expect from a visitor", $swap_list);




Author : Esopo, Read 4415 times, Comments: 2
Rating :  rating resourcesrating resourcesrating resourcesrating resourcesrating resourcesrating resourcesrating resourcesrating resourcesrating resourcesrating resources  |  Sunday, 24. July 2005

Add new comment/Comments
Your rating :   Poor ranking resourcesrating resourcesrating resourcesrating resourcesrating resources Excellent




css stylescss stylesDid you know?
There is a wallpaper gallery? Yeap, it took me a while to code it and put it together for your entertainment. Check it out and, if you like it, drop me a line.
Visit gallery

Featured *
Simple, powerful and reliable. There is not much more you can ask of your FTP. I used to switch FTPs a lot until I found this one; now I never have FTP problems. I do like FTP Voyager’s interface better, but given Filezilla's free nature… what can I say? I got emotionally attached.

An outstanding compilation of some of the best Flash sites out there. As usual with Flash sites, most are useless elaborated animations, but nevertheless worthwhile having a look.
http://www.greg.ch/flash/