note 31532 added to function.unpack

From: Date: Fri, 25 Apr 2003 07:04:01 +0000
Subject: note 31532 added to function.unpack
Groups: php.notes 
Request: Send a blank email to php-notes+get-47062@lists.php.net to get a copy of this message
This is the best example I have found to use unpack. I was finally able to make sense of the documentation afters seeing how they used the function. http://fooassociates.com/phpfer/html/rn45re878.html Quick Example: <? header("Content-type: text/plain"); /* N unsigned long (always 32 bit, big endian byte order) N = 4 bytes "N2int_var" will read 8 bytes into 2 vars int_var1 and int_var2 binary string A324 = decimal 1,093,874,228 binary string &*12 = decimal 640,299,314 C unsigned char "Cchar_var" will read 1 byte into char_var binary string J = decimal 74 */ $assoc_array = unpack("N2int_var/Cchar_var", "A324&*12J"); echo "int_var1 = ", $assoc_array['int_var1'], "\n"; echo "int_var2 = ", $assoc_array['int_var2'], "\n"; echo "char_var = ", $assoc_array['char_var'], "\n"; ?> Sample Output: int_var1 = 1093874228 int_var2 = 640299314 char_var = 74 -- http://www.php.net/manual/en/function.unpack.php http://master.php.net/manage/user-notes.php?action=edit+31532 http://master.php.net/manage/user-notes.php?action=delete+31532 http://master.php.net/manage/user-notes.php?action=reject+31532

« previous php.notes (#47062) next »