note 126265 added to function.ord
| From: | Anonymous at main dot php dot net | Date: | Thu, 22 Jul 2021 18:40:06 +0000 |
| Subject: | note 126265 added to function.ord | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-216637@lists.php.net to get a copy of this message | ||
For anyone who's looking to convert full strings to map and back it's pretty simple but
takes some getting used to...the code below saves an hour of scrounging codes for beginners like
myself.
function var2map($a) {
$b='';
$c=strlen($a);
for($i=0; $i<$c; ++$i) {
$d=ord(substr($a,$i,1));
if($d<10) {
$e='00'.$d;
} else {
if($d<100) {
$e='0'.$d;
} else {
$e=$d;
}
}
if($b=='') {
$b=$e;
} else {
$b=$b.$e;
}
}
return $b;
}
function map2var($a) {
$b='';
$c=strlen($a) / 3;
for($i=0; $i<$c; ++$i) {
$d=chr(substr($a,$i*3,3));
if($b=='') {
$b=$d;
} else {
$b=$b.$d;
}
}
return $b;
}
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 104.194.40.6)
----
Manual Page -- https://php.net/manual/en/function.ord.php
Edit -- https://main.php.net/note/edit/126265
Del: integrated -- https://main.php.net/note/delete/126265/integrated
Del: useless -- https://main.php.net/note/delete/126265/useless
Del: bad code -- https://main.php.net/note/delete/126265/bad+code
Del: spam -- https://main.php.net/note/delete/126265/spam
Del: non-english -- https://main.php.net/note/delete/126265/non-english
Del: in docs -- https://main.php.net/note/delete/126265/in+docs
Del: other reasons-- https://main.php.net/note/delete/126265
Reject -- https://main.php.net/note/reject/126265
Search -- https://main.php.net/manage/user-notes.php