note 52347 added to function.unpack
| From: | MagicalTux at FF dot st | Date: | Thu, 28 Apr 2005 14:17:45 +0000 |
| Subject: | note 52347 added to function.unpack | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-88689@lists.php.net to get a copy of this message | ||
tomlove at gmail dot com gave a code to easily unpack a string. Here's a variant :
<?php
$packed = pack("s*", 123);
list($unpacked) = unpack("s*0", $packed);
?>
$unpacked now holds the value 123, not an array.
unpack() will use numeric keys if you give only numbers (probably same check as is_numeric(), but I
didn't test). This can be useful in some cases (like for getting directly your data without
using arrays).
----
Manual Page -- http://www.php.net/manual/en/function.unpack.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52347
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52347&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52347&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52347&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52347&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52347&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52347&report=yes
Search -- http://master.php.net/manage/user-notes.php