trouble with arrays (part 2)...

From: Date: Mon, 27 Nov 2000 18:07:11 +0000
Subject: trouble with arrays (part 2)...
Groups: php.general 
Request: Send a blank email to php-general+get-27412@lists.php.net to get a copy of this message
I'm having trouble understanding arrays in PHP... can someone help me??? Take a look... Code 1: $req_array; foreach($HTTP_POST_VARS as $field => $value) {
        $req_array[]["name"]=$field;
        $req_array[]["value"]=$value;
} Code 2: $req_array; $i=0; foreach($HTTP_POST_VARS as $field => $value) {
        $req_array[$i]["name"]=$field;
        $req_array[$i]["value"]=$value;
        $i++;
} in Code 1 the array isn't exactly filled like I want it to... it's something like this (I guess) $req_array[0][name] will contain somethin $req_array[0][value] will not even exist $req_array[1][name] will not exist $req_array[2][name] will contain something $req_array[3][value] will contain something... (I guess... I didn't exactly did reverse-engineering on that to see how it works [ debuging in PHP is not as easy as in C ]).. in Code 2 the array is filled exactly the way I want it to... but I have to use an index... and that leads me to this question: is it possible to use the '[]' thing for my "Code 1" purposes? how? thanks... ____________________________ . Christian Dechery (lemming) . http://www.tanamesa.com.br . Gaita-L Owner / Web Developer

« previous php.general (#27412) next »