★ wanayoo — archive 1999 http://www.php.net/manual/function.unpack.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Misc.
Quick Reference
Misc.
* connection_aborted
* connection_status
* connection_timeout
* define
* defined
* die
* eval
* exit
* func_get_arg
* func_get_args
* func_num_args
* function_exists
* get_browser
* ignore_user_abort
* iptcparse
* leak
* pack
* register_shutdown_function
* serialize
* sleep
* uniqid
* unpack
* unserialize
* usleep
Manual: unpack
View the source code for this pageSearch the site



Previous page
 uniqid
unserialize 
Next page


unpack

unpack -- Unpack data from binary string

Description

array unpack (string format, string data)

Unpack() from binary string into array according to format. Returns array containing unpacked elements of binary string.

Unpack() works slightly different from Perl as the unpacked data is stored in an associative array. To accomplish this you have to name the different format codes and separate them by a slash /.

Example 1. Unpack() format string

  1 
  2 $array = unpack ("c2chars/nint", $binarydata);
  3       

The resulting array will contain the entries "chars1", "chars2" and "int".

For an explanation of the format codes see also: pack()

Note that PHP internally stores integral values as signed. If you unpack a large unsigned long and it is of the same size as PHP internally stored values the result will be a negative number even though unsigned unpacking was specified.


User Contributed Notes: unpack


iredden@redden.on.ca
11-Mar-2000 10:34
function parse_pascalstr($bytes_parsed, $parse_str) { $parse_info = unpack("x$bytes_parsed/cstr_len", $parse_str); $str_len = $parse_info["str_len"]; $bytes_parsed = $bytes_parsed + 1; $parse_info = unpack("x$bytes_parsed/A".$str_len."str", $parse_str); $str = $parse_info["str"]; $bytes_parsed = $bytes_parsed + strlen($str); return array($str, $bytes_parsed); }


 About Notes


Previous page
 uniqid
unserialize 
Next page



Site Statistics


Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.