Problem with Adding info into an array
| From: | Phillip Blancher | Date: | Mon, 21 Jul 2003 20:52:22 +0000 |
| Subject: | Problem with Adding info into an array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-156138@lists.php.net to get a copy of this message | ||
In making an array:
I have 7 checkboxes, which make up the array information. I currently use
implode to make the array, however that array only consists of the
information that it checked.
What I need to do now is make it so the array will always be 7 items, but if
there isnt a checkbox for the item, I want inserted to be a 0.
Example
item1[x]
item2[x]
item3[ ]
item4[x]
item5[ ]
item6[x]
item7[ ]
would return = 1,2,0,4,0,6,0
instead of what it does now. 1,2,4,6
I tried placing in the lines before the implode command, saying that:
if($array[0]=="") { $array[0]="0"; } else { }
if($array[1]=="") { $array[1]="0"; } else { }
if($array[2]=="") { $array[2]="0"; } else { }
if($array[3]=="") { $array[3]="0"; } else { }
if($array[4]=="") { $array[4]="0"; } else { }
if($array[5]=="") { $array[5]="0"; } else { }
if($array[6]=="") { $array[6]="0"; } else { }
But this just made the values of the array become blank.
Any suggestions?
Thanks in advance,
Phillip
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.501 / Virus Database: 299 - Release Date: 7/14/2003