473,569 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Working with arrays

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=imp lode(",",$docty pe);
$nomenstr=implo de(",",$nomen) ;
$cagestr=implod e(",",$cage);

print_r(array_u nique($doc));
echo "<BR>Number of elements in DOC: ".count($doc)." <BR>";
print_r($doctyp e);
echo "<BR>Number of elements in DOCTYPE: ".count($doctyp e)."<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
0 1553

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2714
by: michael nieuwenhuizen | last post by:
<newbie alert> i have 2 related arrays that i wanna sort at once. if i try: print_r($my_array1); array_multisort($my_array1, SORT_ASC, $my_array2, SORT_ASC); print_r($my_array1); both arrays remain unsorted. if i try:
5
29236
by: JezB | last post by:
What's the easiest way to concatenate arrays ? For example, I want a list of files that match one of 3 search patterns, so I need something like DirectoryInfo ld = new DirectoryInfo(searchDir); pfiles = ld.GetFiles("*.aspx.resx|") + ld.GetFiles("*.ascx.resx") + ld.GetFiles("*.master.resx"); but of course there is no + operation allowed on...
5
2406
by: Frederic Soustra | last post by:
Hi, I am trying to speed up some work I have to do with a 3D Matrix. If I am not mistaken, C is row major, hence the matrix A of size 2 x 2 x 2 would be stored like this in memory: A,A,A,A,A,A,A,A ? Am I correct, I need to work on Big 3D matrices, and I know that the way
2
6583
by: Gerbus | last post by:
Hi there, I'm working in VC++ 2005 Express, and all I want is to have a dynamic multidimensional array of type Here's my code:
3
1141
by: chrisjob012 | last post by:
hi guys... need some help....!! i am working on a form that looks like a calender....!!... in that form i have added a group box....!! during runtime 30 labels are inserted in it to look like a month display and the labels are added as control arrays........thats working almost fine.... but i would like to have context menu appear in these...
5
1655
by: =?ISO-8859-1?Q?Jonathan_Gro=DF?= | last post by:
Hi everybody, in the sample below my programm gives a "Bus error" on the marked line. I don't get it why that happens. I followed the instructions in the C-FAQ. #include <math.h> #include <stdlib.h> #define dim 2
26
4501
by: tesh.uk | last post by:
Hi Gurus, I have written the following code with the help of Ivor Horton's Beginning C : // Structures, Arrays of Structures. #include "stdafx.h" #include "stdio.h" #define MY_ARRAY 15
8
9061
by: Safy | last post by:
Hello, i really need some help, im new to python so having a bit of trouble. i have two arrays which i successfully pulled out from some data. i want to search these arrays for 2 number and when they appear i want their index. >>> arrF = >>> arrid= >>> def indexOfObjectinFrame2(frame,arrF,arrID,id): ... for i in arrF: ... if arrF ==...
1
2222
by: Stephen.Schoenberger | last post by:
I am working with some images as byte arrays and am not sure nor can I figure out if as I am reading the image and saving smaller sub- images I am reading across and down the image or down and back up or randomly? I need to know so in turn I can realize what the coordinates are of the sub-images. Here is a snippet of the code that is...
20
3720
by: cowboyrocks2009 | last post by:
Hi, I need help to automate my code to take data from input file. Also I need to create it as a function so that I can pass it to some other program. I am new to Java so having a bit limitation to do this. My tab delimited Input File looks like this:- 21 p 13e 0 62 1 580001 andrew -14.53 -13.95 0 0 21 p 13d 63 124 580002 1160001 andrew...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.