note 23264 deleted from function.preg-replace by sander
| From: | sander@php.net | Date: | Sat, 15 Feb 2003 15:21:32 +0000 |
| Subject: | note 23264 deleted from function.preg-replace by sander | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-43979@lists.php.net to get a copy of this message | ||
This took me a little while to figure out, even though it's quite simple.
If you want to break up a string by each character, you can use this:
<?php
$num = "12345";
print preg_replace("/(\d)/", "<img src='numbers/$1.gif'>",
$num);
This would output the image code with 1, 2, 3, 4 & 5 replacing $1 for each case.
Hope this helps!