note 114431 added to function.pack

From: Date: Thu, 20 Feb 2014 04:20:57 +0000
Subject: note 114431 added to function.pack
Groups: php.notes 
Request: Send a blank email to php-notes+get-198556@lists.php.net to get a copy of this message
How to convert an integer to raw data, specifying the amount of bytes to convert to (will be padded with 0's): public function toRaw($int, $bytes = 4) { $hex = dechex($int); if (strlen($hex) % 2 != 0) $hex = '0'. $hex; $arr = str_split($hex, 2); while (count($arr) < $bytes) array_unshift($arr, 0); $arr = array_map('hexdec', $arr); $arr = array_map('chr', $arr); return join('', array_reverse($arr)); } ---- Server IP: 113.20.13.217 Probable Submitter: 121.223.232.23 ---- Manual Page -- http://php.net/manual/en/function.pack.php Edit -- https://master.php.net/note/edit/114431 Del: integrated -- https://master.php.net/note/delete/114431/integrated Del: useless -- https://master.php.net/note/delete/114431/useless Del: bad code -- https://master.php.net/note/delete/114431/bad+code Del: spam -- https://master.php.net/note/delete/114431/spam Del: non-english -- https://master.php.net/note/delete/114431/non-english Del: in docs -- https://master.php.net/note/delete/114431/in+docs Del: other reasons-- https://master.php.net/note/delete/114431 Reject -- https://master.php.net/note/reject/114431 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#198556) next »