Ask a Question related to PHP Development, Design and Development.
-
Hilarion #1
Re: ereg_replace
> $linked_comments = ereg_replace("\n","<br>",$linked_comments");
Try:
$linked_comments = str_replace("\r\n","\n",$linked_comments");
$linked_comments = str_replace("\n","<br>",$linked_comments");
If you do not use regular expression for replacement, than
use str_replace instead of ereg_replace, wchich requires
esapeing spesial chars (I believe than newline char is special
char in regexp).
Hilarion
Hilarion Guest
-
Daft ereg_replace() question.....
I thought this would be easy, but have wasted the best part of 2 hrs trying to make it work I have a string: $string = "!!shocking.jpg"; I... -
ereg_replace at PHP > 4.3.2
Is there anything change in "ereg_replace()" PHP > 4.3.2. Scripts works in PHP 4.3.1 but NOT in PHP 4.3.2: $text = "<!-- test -->"; $text =... -
#25399 [Opn->Bgs]: ereg_replace problem
ID: 25399 Updated by: sniper@php.net Reported By: ibar at 163 dot com -Status: Open +Status: Bogus... -
#25399 [NEW]: ereg_replace problem
From: ibar at 163 dot com Operating system: Redhat 7.2 PHP version: 4.3.3 PHP Bug Type: Scripting Engine problem Bug... -
better understanding of ereg_replace and other functions
Hi everybody, Lot of places in manual i came across using "ereg_replace" or "ereg" is very resource intensive and hence its better to use... -
:::bc78::: #2
ereg_replace
I'm using a piece of code i have used before with success only this time it
doesn't seem to want to work, can anybody tell me where i've gone wrong with
the following:
-------CODE START-------
$linked_comments=$comments_myrow["comment"];
$linked_comments=stripslashes($linked_comments);
$linked_comments = emoticon($linked_comments);
$linked_comments = ereg_replace("\n","<br>",$linked_comments");
$comments_author=$comments_myrow["author"];
$comments_date=$comments_myrow["date_format(date, '%D %M %Y')"];
$comments_time=$comments_myrow["date_format(date, '%H:%i')"];
if ($SDK->is_supermod()) {
$moderate = '<strong>- <a
href="admin/comments_moderate.php?comment='.$ID.'&storyID= '.$storyID.'">
Moderate this post</a></strong>'; }
?>
<tr>
<td>
<div align="justify" class='thin1'><?php echo("<strong><a
href='".$SDK->board_url."/index.php?showuser=".$comments_author."'>".$SDK->i
d2name($comments_author)."</a></strong><span class='edit'> -
$comments_date - ".$comments_time."gmt
".$moderate."</span><br>$linked_comments"); ?></div>
-------CODE END-------
What I want to happen is every newline to be replaced with a <br> tag but in
this instance it doesn't, the new lines are definately stored in the
database. Can anyone help please?
:::bc78::: Guest
-
eclipsboi #3
Re: ereg_replace
All regular expressions need to be surrounded by slashes. For example:
$linked_comments = ereg_replace("/\n/", "<br>", $linked_comments);
But, as Hilarion pointed out, in your case, you don't need regexp
On Fri, 6 Aug 2004 15:15:12 +0200, "Hilarion"
<hilarion@SPAM.op.SMIECI.pl> wrote:
>>> $linked_comments = ereg_replace("\n","<br>",$linked_comments");
>Try:
>
>$linked_comments = str_replace("\r\n","\n",$linked_comments");
>$linked_comments = str_replace("\n","<br>",$linked_comments");
>
>If you do not use regular expression for replacement, than
>use str_replace instead of ereg_replace, wchich requires
>esapeing spesial chars (I believe than newline char is special
>char in regexp).
>
> Hilarion
>eclipsboi Guest



Reply With Quote

