By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,722 Members | 1,227 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,722 IT Pros & Developers. It's quick & easy.

Working with arrays

P: n/a
Hi:

I have a form with 4 arrays in it. Each array can contain up to 11
elements.

I am using the following code (this is for proof of concept):

<?

if($submit) {

foreach ($_POST['doc'] as $doc1) {
}
foreach ($_POST['doctype'] as $doctype1) {
}
foreach ($_POST['nomen'] as $nomen1) {
}
foreach ($_POST['cage'] as $cage1) {
}
$docstr=implode(",",$doc);
$doctypestr=implode(",",$doctype);
$nomenstr=implode(",",$nomen);
$cagestr=implode(",",$cage);

print_r(array_unique($doc));
echo "<BR>Number of elements in DOC: ".count($doc)."<BR>";
print_r($doctype);
echo "<BR>Number of elements in DOCTYPE: ".count($doctype)."<BR>";
print_r($nomen);
echo "<BR>Number of elements in NOMEN: ".count($nomen)."<BR>";
print_r($cage);
echo "<BR>Number of elements in CAGE: ".count($cage)."<BR>";

}
else
{
?>

<form METHOD=POST ACTION=test.php>

<TABLE BORDER="2">
<TR>
<TD>Enter Doc # 0 <INPUT TYPE=text NAME=doc[]></TD>
<TD>Enter DocType 0 <INPUT TYPE=text
NAME=doctype[]></TD>
<TD>Enter Nomen 0 <INPUT TYPE=text NAME=nomen[]></TD>
<TD>Enter Cage 0 <INPUT TYPE=text NAME=cage[]></TD>
</TR>
<TR>
<TD>Enter Doc # 1 <INPUT TYPE=text NAME=doc[]></TD>
<TD>Enter DocType 1 <INPUT TYPE=text
NAME=doctype[]></TD>
<TD>Enter Nomen 1 <INPUT TYPE=text NAME=nomen[]></TD>
<TD>Enter Cage 1 <INPUT TYPE=text NAME=cage[]></TD>
</TR>
<TR>
<TD>Enter Doc # 2 <INPUT TYPE=text NAME=doc[]></TD>
<TD>Enter DocType 2 <INPUT TYPE=text
NAME=doctype[]></TD>
<TD>Enter Nomen 2 <INPUT TYPE=text NAME=nomen[]></TD>
<TD>Enter Cage 2 <INPUT TYPE=text NAME=cage[]></TD>
</TR>
<TR>
<TD>Enter Doc # 3 <INPUT TYPE=text NAME=doc[]></TD>
<TD>Enter DocType 3 <INPUT TYPE=text
NAME=doctype[]></TD>
<TD>Enter Nomen 3 <INPUT TYPE=text NAME=nomen[]></TD>
<TD>Enter Cage 3 <INPUT TYPE=text NAME=cage[]></TD>
</TR>
<TR>
<TD>Enter Doc # 4 <INPUT TYPE=text NAME=doc[]></TD>
<TD>Enter DocType 4 <INPUT TYPE=text
NAME=doctype[]></TD>
<TD>Enter Nomen 4 <INPUT TYPE=text NAME=nomen[]></TD>
<TD>Enter Cage 4 <INPUT TYPE=text NAME=cage[]></TD>
</TR>
<TR>
<TD>Enter Doc # 5 <INPUT TYPE=text NAME=doc[]></TD>
<TD>Enter DocType 5 <INPUT TYPE=text
NAME=doctype[]></TD>
<TD>Enter Nomen 5 <INPUT TYPE=text NAME=nomen[]></TD>
<TD>Enter Cage 5 <INPUT TYPE=text NAME=cage[]></TD>
</TR>
<TR>
<TD>Enter Doc # 6 <INPUT TYPE=text NAME=doc[]></TD>
<TD>Enter DocType 6 <INPUT TYPE=text
NAME=doctype[]></TD>
<TD>Enter Nomen 6 <INPUT TYPE=text NAME=nomen[]></TD>
<TD>Enter Cage 6 <INPUT TYPE=text NAME=cage[]></TD>
</TR>
<TR>
<TD>Enter Doc # 7 <INPUT TYPE=text NAME=doc[]></TD>
<TD>Enter DocType 7 <INPUT TYPE=text
NAME=doctype[]></TD>
<TD>Enter Nomen 7 <INPUT TYPE=text NAME=nomen[]></TD>
<TD>Enter Cage 7 <INPUT TYPE=text NAME=cage[]></TD>
</TR>
<TR>
<TD>Enter Doc # 8 <INPUT TYPE=text NAME=doc[]></TD>
<TD>Enter DocType 8 <INPUT TYPE=text
NAME=doctype[]></TD>
<TD>Enter Nomen 8 <INPUT TYPE=text NAME=nomen[]></TD>
<TD>Enter Cage 8 <INPUT TYPE=text NAME=cage[]></TD>
</TR>
<TR>
<TD>Enter Doc # 9 <INPUT TYPE=text NAME=doc[]></TD>
<TD>Enter DocType 9 <INPUT TYPE=text
NAME=doctype[]></TD>
<TD>Enter Nomen 9 <INPUT TYPE=text NAME=nomen[]></TD>
<TD>Enter Cage 9 <INPUT TYPE=text NAME=cage[]></TD>
</TR>
<TR>
<TD>Enter Doc # 10 <INPUT TYPE=text NAME=doc[]></TD>
<TD>Enter DocType 10 <INPUT TYPE=text
NAME=doctype[]></TD>
<TD>Enter Nomen 10 <INPUT TYPE=text NAME=nomen[]></TD>
<TD>Enter Cage 10 <INPUT TYPE=text NAME=cage[]></TD>
</TR>
</TABLE>

<INPUT TYPE=submit NAME=submit VALUE=Submit>

</form>

<?
}
?>

My question is how can I NOT have blank elements counted/displayed?

Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.