> -----Original Message----- > From: Daevid Vincent [mailto:daevid@;daevid.com] > Sent: 06 November 2002 12:23 > To: [EMAIL PROTECTED] > > 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? ;-)
Nah, that's dead easy: $mask = str_repeat("0", number_of_books_to_be_tracked); foreach($purchitem as $book_no): $mask{$book_no} = "1"; endforeach; Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php