Re: long PHP array and HTML forms question

From: Date: Thu, 06 Jun 2002 15:00:41 +0000
Subject: Re: long PHP array and HTML forms question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-100939@lists.php.net to get a copy of this message
Jason Wong wrote:
Page 2: I want the user to be able to use none, some, or all of the fields, so I don't know how many elements will be in the array. $color[] = $_POST["color"];
That should be: $color = $_POST["color"]; Actually from your results below it seems like you've enabled register_globals and it's not necessary to explicit (re)assign $color.
Right. I'm used to working on a machine that doesn't have register_globals enabled, so it's just habit. Unfortunately, that particular hosting provider enables them.
First question: is there something I can do at this point to cut the empty entries
foreach ($color as $key => $val) { if ($val) {
    $tmp[] = $val;
} } $color = $tmp; That will remove empty values from $color.
Ahh. That's exactly what I needed! Thanks, Steven Steven Jarvis Web Developer Arkansas Democrat-Gazette Northwest Edition

« previous php.general (#100939) next »