note 50700 added to function.str-replace

From: Date: Mon, 07 Mar 2005 17:41:46 +0000
Subject: note 50700 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-86060@lists.php.net to get a copy of this message
str_replace can do many things, including smileys, bad word replacement, and even manually taking out bad HTML code. doing smileys is easy, first, create a jpg called smiley and add the following code to your form handling script: $posting = str_replace(":)", "<img src=smiley.jpg width=50 height=50>", $posting); also, taking out bad words is easy, too: $posting = str_replace("badword", "*******", $posting); then, lets say you want a form handler that keeps some HTML code to let people do things like post images, but not let them change the page's formatting. use str_replace! $posting = str_replace("BADHTMLCODE", "", $posting); finally, you can even make a scripting language like vBcode, like this: $posting = str_replace("[IMG]", "<img src>", $posting); $posting = str_replace("[URL]", "<a href>", $posting); $posting = str_replace("[/URL]", "</a>", $posting); $posting = str_replace("[CODE]", "<pre><p>code:</p>", $posting); $posting = str_replace("[/CODE]", "</pre>", $posting); The list of things you can do goes on and on! ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+50700 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50700&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50700&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50700&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50700&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50700&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+50700&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86060) next »