suggestion for new function str_change(string str,array transtable [,bool reverse])
| From: | Thies C. Arntzen | Date: | Sat, 20 Nov 1999 10:25:58 +0000 |
| Subject: | suggestion for new function str_change(string str,array transtable [,bool reverse]) | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-6564@lists.php.net to get a copy of this message | ||
lets start with this - i don't like the name
function should search/replace a number of pairs in str and return the new
string.
sample:
$trans = array("ü" => "ue","ß" => "ss"); // expand
german umlauts
$data = str_change("üß",$trans); // $data will be "uess";
// 3th argumet changed the "direction" in the transtable
$data = str_change($data,$trans,true); // $data will be "üß" again.
this function will make it easy to eg reverse an htmlspecialchars(). we
could also make the table used by htmlspecialchars() and
htmlentites() accessible in transtable format:
$tt = get_htmltable(ISO-8859-1); // returns "EntTable" from html.c
$plaindata = str_change($htmlencodeddata,$tt,1); // reverse htmlentities
does that make sense? (any better ideas?)
tc
Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!"
Digital Collections Phone +49 40 235350 Fax +49 40 23535180
Hammerbrookstr. 93 20097 Hamburg / Germany