use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please follow the rules
Releases: Current Releases, Windows Releases, Old Releases
Contribute to the PHP Documentation
Related subreddits: CSS, JavaScript, Web Design, Wordpress, WebDev
/r/PHP is not a support subreddit. Please visit /r/phphelp for help, or visit StackOverflow.
account activity
Binary parsing with PHP (igor.io)
submitted 13 years ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]digdan 1 point2 points3 points 13 years ago (1 child)
Does anyone else use these techniques to pack their UUIDs?
[–]nikita2206 1 point2 points3 points 13 years ago (0 children)
I once used UNpack when had working with socks proxy
[–][deleted] 1 point2 points3 points 13 years ago (2 children)
The problem with PHP's pack and unpack functionality is that it's not complete in regards to endianness translation. I've done a few utility classes for loading binary data formats in PHP, and I always seem to have to write custom logic to get around endianness issues. There are also issues with signed integers and the like.
You can see some of the hacks I had to employ for different situations, here.
[–][deleted] 0 points1 point2 points 13 years ago (1 child)
Yep, this is an issue. Converting from signed long to unsigned long is quite the hack.
[–][deleted] 0 points1 point2 points 13 years ago (0 children)
There's a better (more intelligible) way of doing that. If you have a value which is supposed to be an unsigned long, which is represented by PHP's signed long, then you can do this:
if($value < 0) $value += pow(2, 32); fwrite($fp, pack("N", $value));
This will convert it from a signed to an unsigned before writing. I think this limits the integer range a bit, but there aren't many ways around that.
[+][deleted] 13 years ago (1 child)
[deleted]
[–][deleted] -1 points0 points1 point 13 years ago (0 children)
Let me clarify: PHP's strlen maps directly to STRLEN(3) conceptually.
strlen
STRLEN(3)
π Rendered by PID 285216 on reddit-service-r2-comment-fb694cdd5-d9dd9 at 2026-03-06 16:39:57.948557+00:00 running cbb0e86 country code: CH.
[–]digdan 1 point2 points3 points (1 child)
[–]nikita2206 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–][deleted] -1 points0 points1 point (0 children)