> That's the EASY part John!
> 
> The hard part is converting the array (which was a checkbox array from
a
> form submission) into the binary string (as per the original post)
> 
> > Here's the deal. Given an array such that:
> > $purchitem[0] = 1;  //purchased book #1 checkbox enabled
> > $purchitem[1] = 3;  //purchased book #3 checkbox enabled
> > $purchitem[2] = 4;  //purchased book #4 checkbox enabled
> > I want to end up with a variable like this:
> > $mask = "10110";
> 
> Get it now? ;-)

Got it...

Are there always going to be X digits in the code? If so, this would
work.

<?
$purchitem[0] = 1;
$purchitem[1] = 3;
$purchitem[2] = 4;  


$mask = '';
$length = 5;
$y = 0;

for($x=1;$x<$length+1;$x++)
{
  if(@$purchitem[$y] == $x)
  { 
    $mask .= '1'; 
    $y++;
  }
  else
  { $mask .= '0'; }
}

echo $mask;

?>

---John Holmes...  





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to