note 42595 deleted from function.str-replace by bjori

From: Date: Sun, 26 Mar 2006 22:22:17 +0000
Subject: note 42595 deleted from function.str-replace by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106668@lists.php.net to get a copy of this message
Note Submitter: aeron at aeronius dot org ---- Here's something I used to utilize str_replace in a script, by using it to replace text with graphic images.. say, if you had a counter or whatnot, and wanted a way to make the counter's results graphical: <? // For here, we're going to create a $ number .. $num = 56; // now, for the str_replace arrays. We'll need these to make the replacements. // digits to search for $nums = array ( "1", "2", "3", "4", "5", "6", "7", "8", "9", "0" ); // images array to replace them with. $images = array ( "<img src=1.gif>", "<img src=2.gif>" , "<img src=3.gif>" ); // continue with the <img src>'s with the number pattern above. // Now, for the function to do all the replacing. $final = str_replace ($nums, $images, $num); echo $final; ?> Quite simple, really.

« previous php.notes (#106668) next »