note 75574 added to language.types.string
| From: | rheel at onedropsolutions dot de | Date: | Wed, 06 Jun 2007 09:54:33 +0000 |
| Subject: | note 75574 added to language.types.string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-127246@lists.php.net to get a copy of this message | ||
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);
}
?>
----
Server IP: 217.160.72.57
Probable Submitter: 212.77.165.180
----
Manual Page -- http://www.php.net/manual/en/language.types.string.php
Edit -- https://master.php.net/note/edit/75574
Del: integrated -- https://master.php.net/note/delete/75574/integrated
Del: useless -- https://master.php.net/note/delete/75574/useless
Del: bad code -- https://master.php.net/note/delete/75574/bad+code
Del: spam -- https://master.php.net/note/delete/75574/spam
Del: non-english -- https://master.php.net/note/delete/75574/non-english
Del: in docs -- https://master.php.net/note/delete/75574/in+docs
Del: other reasons-- https://master.php.net/note/delete/75574
Reject -- https://master.php.net/note/reject/75574
Search -- https://master.php.net/manage/user-notes.php