At 13:43 06.11.2002, Daevid Vincent said:
>Ernest, close but you have it reversed for my needs (i.e. true binary
>form). Notice that my LSB is to the left, not right.

Ah, ic, you want a <<string>> like "00001100101" - that's easy :)
Note that I do _not_ pass the array by reference here since I modify it
(using asort).

function make_a_special_bitlike_string($array)
        $result = '';
        sort($array, SORT_NUMERIC);
        $max = $array[count($array)-1];
        for ($i = 1; $i <= $max; ++$i) {
                if (in_array($i, $array))
                        $result .= '1';
                        $result .= '0';
       return $result;

if you need this as a number, simply return "(int)$result", but beware that
this breaks if there are more than 32 digits (highest value > 32).

   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to