trouble with arrays...

From: Date: Mon, 27 Nov 2000 00:00:22 +0000
Subject: trouble with arrays...
Groups: php.general 
Request: Send a blank email to php-general+get-27289@lists.php.net to get a copy of this message
I'm trying to check for required fields... (in this case, all are required fields)... so I do this... $req_array; foreach($HTTP_POST_VARS as $field => $value) { if(1) { $req_array[]["name"]=$field; $req_array[]["value"]=$value; } } when I do this... the array is filled correctly, but when I do this. (I'm doing this only for testing... I know it's stupid to record values of non-filed fields.. I'm filling them just for testing and form me to learn arrays) echo "<center>You haven't filled the following <b>fields</b>:</center><br>\n"; reset($req_array); field=current($req_array); while($field!=false) { echo "<center>\n<font color=ff0000>\n<b>$field[name]</b>"; echo "$field[value]\n</font>\n</center>"; $field=next($req_array); } and this is what it prints... <center>You haven't filled the following <b>fields</b>:</center><br> <center> <font color=ff0000> <b>name</b> </font> <= where did this came from? </center><center> <= and this? <font color=ff0000> <b></b>john </font> </center><center> <font color=ff0000> <b>lastname</b> </font> </center><center> <font color=ff0000> <b></b>doe </font> </center> other thing... if in the firs code... I do this: $req_array; $i=0; foreach($HTTP_POST_VARS as $field => $value) { if(1) { $req_array[$i]["name"]=$field; $req_array[$i]["value"]=$value; $i++; } } the crazy "</font></center>" doesn't appear... anyone have a clue??? it's probably a stupid array mistake... but it would help me a lot if someone exaplained me what is happening! :) thanks... ____________________________ . Christian Dechery (lemming) . http://www.tanamesa.com.br . Gaita-L Owner / Web Developer

« previous php.general (#27289) next »