a simple

<snip>
        for($i=0; $i<sizeof($array); $++)
                $array[$i]=trim($array[$i]);
</snip>

will do the trick

 Cheers,

 Maxim Maletsky
 Founder, Chief Developer

 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com



-----Original Message-----
From: Thomas Deliduka [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 03, 2001 7:32 AM
To: PHP List
Subject: [PHP] "Trim" an array?


I looked through the archives and couldn't find anything on this.

I have a web form which takes 9 values to create a definition for a table
that would have up to 9 columns.

I made the table so that each form field is submitted as an array so that I
can simply step through each value and create the table definition, so:

<input type=text name="tblcol[]">  (duplicated 9 times)

Now, when I submit the form the resulting array always has 9 elements and
some of those will be empty.

I would like to do error checking in case people didn't fill anything at all
so I thought using if (!count($tblcol)) {.... But that doesn't work since it
always has 9 elements.

Is there a way to find out if an array contains no values even though it has
elements?  Sort of like a trim() function on an array to destroy the
elements in the array that are empty.

Is it possible?
--

Thomas Deliduka
IT Manager
     -------------------------
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to