note 56629 deleted from function.str-replace by bjori
| From: | bjori@php.net | Date: | Sun, 26 Mar 2006 22:21:52 +0000 |
| Subject: | note 56629 deleted from function.str-replace by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-106666@lists.php.net to get a copy of this message | ||
Note Submitter: dsi at danielsecuritiesinc dot com
----
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("\"",""",$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);
}
?>