note 45188 added to function.unpack

From: Date: Sat, 28 Aug 2004 19:32:51 +0000
Subject: note 45188 added to function.unpack
Groups: php.notes 
Request: Send a blank email to php-notes+get-75504@lists.php.net to get a copy of this message
If having a zero-based index is useful/necessary, then instead of: $int_list = unpack("s*", $some_binary_data); try: $int_list = array_merge(unpack("s*", $some_binary_data)); This will return a 0-based array: $int_list[0] = x $int_list[1] = y $int_list[2] = z ... rather than the default 1-based array returned from unpack when no key is supplied: $int_list[1] = x $int_list[2] = y $int_list[3] = z ... It's not used often, but array_merge() with only one parameter will compress a sequentially-ordered numeric-index, starting with an index of [0]. ---- Manual Page -- http://www.php.net/manual/en/function.unpack.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45188 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45188&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45188&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#75504) next »