note 105878 added to ref.strings

From: Date: Thu, 22 Sep 2011 14:36:57 +0000
Subject: note 105878 added to ref.strings
Groups: php.notes 
Request: Send a blank email to php-notes+get-183344@lists.php.net to get a copy of this message
Someone posted a str2bin fonction, this is a simpler version, using more PHP internal functions. <?php /** * Returns an ASCII string containing * the binary representation of the input data . **/ function str2bin($str, $mode=0) { $out = false; for($a=0; $a < strlen($str); $a++) { $dec = ord(substr($str,$a,1)); $bin = decbin($dec); $bin = str_pad($bin, 8, "0", STR_PAD_LEFT); /* Default-mode */ if ( $mode == 0 ) $out .= $bin; /* Human-mode (easy to read) */ if ( $mode == 1 ) $out .= $bin . " "; /* Array-mode (easy to use) */ if ( $mode == 2 ) $out[$a] = $bin; } return $out; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 69.70.89.66 ---- Manual Page -- http://www.php.net/manual/en/ref.strings.php Edit -- https://master.php.net/note/edit/105878 Del: integrated -- https://master.php.net/note/delete/105878/integrated Del: useless -- https://master.php.net/note/delete/105878/useless Del: bad code -- https://master.php.net/note/delete/105878/bad+code Del: spam -- https://master.php.net/note/delete/105878/spam Del: non-english -- https://master.php.net/note/delete/105878/non-english Del: in docs -- https://master.php.net/note/delete/105878/in+docs Del: other reasons-- https://master.php.net/note/delete/105878 Reject -- https://master.php.net/note/reject/105878 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183344) next »