PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Sat Aug 07, 2004 6:06 pm
Oke.. i have the following wich kinda works however not what i want or need.
Code: Select all
$message = nl2br($file_content);
$pattern = array("#<br />#","#<u>#","#</u>#","#<b>#","#</b>#");
$replacement = "";
echo '<TEXTAREA NAME="" ROWS="20" COLS="50">';
echo preg_replace($pattern, $replacement, $message);
echo '</TEXTAREA>';
This will replace all with 'nothing' basicly, but what if i want to replace only <br /> with nothing and the others with
for example.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Aug 07, 2004 6:09 pm
make an array of $replacement.
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Sat Aug 07, 2004 11:47 pm
Thanks..
Oke i got it working for replacing
with </b>
however how to replace
[.color= red] sometext[./color]
with
<font color="red">some text</font>
Another thing:
The following is not working nicely lol it wont insert with the html tags
has a nice effect tho jejejeje
Code: Select all
<?
$message = nl2br($row_indexї'bodyContent']);
$pattern = array("#<br />#","#<u>#","#</u>#","#<b>#","#</b>#");
$replacement = array("","їu]","ї/u]","їb]","ї/b]");
echo preg_replace($pattern, $replacement, $message);
echo '</textarea>';
echo '<INPUT TYPE="submit" name="submit" value="Display">';
echo '</form>';
echo '</span></td>';
mysql_free_result($index);
if (isset($_POSTї'submit']))
{
$pattern = array("#їu]#","#ї/u]#","#їb]#","#ї/b]#");
$replacement = array("<u>","</u>","<b>","</b>");
$replace_text = nl2br(preg_replace($pattern, $replacement, $message));
require_once($_SERVERї'DOCUMENT_ROOT'] .'/Connections/fd.php');
mysql_select_db($database_fd, $fd);
$query = "UPDATE indexcontent SET bodyContent='".$update_text."' WHERE pageID='".$_GETї'action']."'";
$result=mysql_query($query);
echo $query;
}
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 08, 2004 12:37 am
[] are special tags in preg_* functions... you need to escape them. As for doing the color code.. download phpbb and look at their bbcode script.
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Sun Aug 08, 2004 12:39 am
Any short explanation on how i should escape them?
And maby some on the color thing?
Edit:
Code: Select all
got it :)
$pattern = array("#\їu]#","#\ї/u]#","#\їb]#","#\ї/b]#");
Help on the color thing would be nice tho
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 08, 2004 12:42 am
just download the bbcode script that phpbb uses...
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Sun Aug 08, 2004 12:46 am
Thats a hell of a scirpt to downlaod, and to search true lol..
You might find that very easy, but i do not.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 08, 2004 12:48 am
bbcode.php wrote: Code: Select all
$text = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+):$uid\]/si", $bbcode_tpl['color_open'], $text);
yeah realllll hard...
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Sun Aug 08, 2004 1:11 am
This is kinda my first real day that i am messing with it. So what is easy for you might not be as easy for other people.
Could you be so nice which page ?
Thanks very much anyway.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Aug 08, 2004 1:14 am
bbcode.php.. in phpbb's code tree..
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Sun Aug 08, 2004 3:20 am
Or get the PEAR::HTML_BBCode package. Can be easily adapted to run without all those other pear thiingies..