note 103633 added to function.pack
| From: | DavidGerodave at havidave dot com | Date: | Mon, 25 Apr 2011 14:47:26 +0000 |
| Subject: | note 103633 added to function.pack | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179118@lists.php.net to get a copy of this message | ||
You might find these functions useful:
<?php
function byteStr2byteArray($s) {
return array_slice(unpack("C*", "\0".$s), 1);
}
function byteArray2byteStr(array $t) {
return call_user_func_array(pack, array_merge(array("C*"), $t));
}
function lsbStr2ushortArray($s) {
return array_slice(unpack("v*", "\0\0".$s), 1);
}
function ushortArray2lsbStr(array $t) {
return call_user_func_array(pack, array_merge(array("v*"), $t));
}
function lsbStr2ulongArray($s) {
return array_slice(unpack("V*", "\0\0\0\0".$s), 1);
}
function ulongArray2lsbStr(array $t) {
return call_user_func_array(pack, array_merge(array("V*"), $t));
}
?>
Of course, you can address byte strings as if they're arrays with numerical indexes, but the
other functions are helpful.
----
Server IP: 66.207.199.35
Probable Submitter: 173.33.54.15
----
Manual Page -- http://www.php.net/manual/en/function.pack.php
Edit -- https://master.php.net/note/edit/103633
Del: integrated -- https://master.php.net/note/delete/103633/integrated
Del: useless -- https://master.php.net/note/delete/103633/useless
Del: bad code -- https://master.php.net/note/delete/103633/bad+code
Del: spam -- https://master.php.net/note/delete/103633/spam
Del: non-english -- https://master.php.net/note/delete/103633/non-english
Del: in docs -- https://master.php.net/note/delete/103633/in+docs
Del: other reasons-- https://master.php.net/note/delete/103633
Reject -- https://master.php.net/note/reject/103633
Search -- https://master.php.net/manage/user-notes.php