note 56629 added to function.str-replace

From: Date: Sat, 10 Sep 2005 02:00:15 +0000
Subject: note 56629 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-94975@lists.php.net to get a copy of this message
One of the more powerful uses of this is when parsing a .txt file using PHP. You can make it easy on yourself to create logs, blogs, or dynamic text merely by having PHP do str_replace() on things that are not HTML/XHTML complient, such as quotation marks. Here's a quick/dirty example: <?php function replaceText($text,$gap,$class){ //get rid of quotation marks $text=str_replace("\"","&quot;",$text); //get rid of double spaces (not tabs) //since double spaces in text don't show anyway $text=str_replace(" "," ",$text); //Windows files do \r\n, this is for a file created //in Windows $text=str_replace("\r","</p>",$text); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56629 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56629&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56629&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56629&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56629&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56629&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56629&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56629&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94975) next »