note 63783 added to function.str-replace

From: Date: Thu, 30 Mar 2006 15:40:40 +0000
Subject: note 63783 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-107037@lists.php.net to get a copy of this message
As an effort to remove those Word copy and paste smart quotes, I've found that this works with UTF8 encoded strings (where $text in the following example is UTF8). Also the elipsis and em and en dashes are replaced. There is an "invisible" character after the †for the right side double smart quote that doesn't seem to display here. It is chr(157). <?php $find[] = '“'; // left side double smart quote $find[] = '”'; // right side double smart quote $find[] = '‘'; // left side single smart quote $find[] = '’'; // right side single smart quote $find[] = '…'; // elipsis $find[] = '—'; // em dash $find[] = '–'; // en dash $replace[] = '"'; $replace[] = '"'; $replace[] = "'"; $replace[] = "'"; $replace[] = "..."; $replace[] = "-"; $replace[] = "-"; $text = str_replace($find, $replace, $text); ?> ---- Server IP: 216.235.15.211 Probable Submitter: 204.187.63.106 (proxied: 1.0 PORTIA) ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- http://master.php.net/note/edit/63783 Del: integrated -- http://master.php.net/note/delete/63783/integrated Del: useless -- http://master.php.net/note/delete/63783/useless Del: bad code -- http://master.php.net/note/delete/63783/bad+code Del: spam -- http://master.php.net/note/delete/63783/spam Del: non-english -- http://master.php.net/note/delete/63783/non-english Del: in docs -- http://master.php.net/note/delete/63783/in+docs Del: other reasons-- http://master.php.net/note/delete/63783 Reject -- http://master.php.net/note/reject/63783 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#107037) next »