> -----Original Message-----
> From: leledumbo [mailto:leledumbo_c...@yahoo.co.id]
> Sent: 10 August 2009 11:11
> To: php-general@lists.php.net
> Subject: RE: [PHP] Radio buttons problem
> 
> 
> > Why do you? There's no reason you *have* to have consecutive
> indexes --
> just iterate over the resulting > array with foreach, and there's no
> problem.
> 
> There is, the entries are grouped by its index. So, I group name[0],
> email[0], and sex[0] as one. The problem if I don't maintain the
> index for
> radio buttons, the index could go wrong.
> 
> In the previous example I gave, if entry2 is deleted (and I don't
> maintain
> the index) then entry3 will contain name[1], email[1], and sex[2]
> which
> isn't desirable.

Huh???

If you have entries for:

   name[0], email[0], sex[0]
   name[1], email[1], sex[1]
   name[2], email[2], sex[2]
   ...

and then delete the entry containing sex[1], why wouldn't you just end up with

   name[0], email[0], sex[0]
   name[2], email[2], sex[2]
   ...

???

Unless, of course, what you have is

   name[], email[], sex[0]
   name[], email[], sex[1]
   name[], email[], sex[2]
   ...

... in which case, don't do that!  If it's important to you that the indexes 
match across name[], email[] and sex[], then you must supply them explicitly 
for every field in the group -- if you name some of the fields with [], and 
some with explicit [1], [2] indexes, you're setting yourself up for exactly 
this kind of mismatch problem when you come to delete (or insert!) entries.

Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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

Reply via email to