note 75574 deleted from language.types.string by tularis
| From: | tularis@php.net | Date: | Fri, 08 Jun 2007 12:45:00 +0000 |
| Subject: | note 75574 deleted from language.types.string by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127310@lists.php.net to get a copy of this message | ||
Note Submitter: rheel at onedropsolutions dot de
Reason: useless
----
This function converts a string with a literal (e.g. '\n') in it's real character
(e.g. "\n"):
<?php
function decode($string){
$search=array('\n','\r','\t','\\','\$','\"');
$replace=array("\n","\r","\t","\\","\$","\"");
$ret=str_replace($search,$replace,$string);
if(ereg('\\\[0-7]{1,3}',$ret,$found)){
foreach($found as $oct){
$ret=str_replace($oct,chr(octdec(substr($oct,1))),$ret);
}
}
if(ereg('\\\x[0-9A-Fa-f]{1,2}',$ret,$found)){
foreach($found as $hex){
$ret=str_replace($hex,chr(hexdec(substr($hex,2))),$ret);
}
}
return($ret);
}
?>