"[XaToA]" <gr****************@latinmail.com> wrote in message
news:bf************@ID-59646.news.uni-berlin.de...
Hello
Whit this:
<?php echo str_replace ( "\r", "<br/>", $arr[texto]) ; ?>
i replace the \r with the <br/>
but i must analyze one String and see if there is into the String:
1, 2, 3, 4, 5, 6, 7, 8, 9, 0
and replace those characters with <br/>
can anybody help me?
thanks
First, make sure there's a space in your "br" tag: <br /> not <br/>.
Netscape used to have some issues when you left out the space.
Look up the Regular Expression functions in the manual. Here's how you
could accomplish your current task:
<? echo preg_replace('/[0-9]/', '<br />', $arr['texto']); ?>
Of course, this will replace any digit with a <br /> tag. If you had
something like "25" in your string, it would be replaced with "<br /><br />"
If you want to be more sophisticated, you could set the digit on a word
boundary:
preg_replace('/\b[0-9]\b/', '<br />', $arr['texto']);
This would replace any single digit with a <br /> tag.
As you can see, the specifications of your problem must be very specific if
you want it to behave like you expect. Learn how to use regular expressions
and your life will be much easier.
HTH,
Zac