Re: [PHP] Newbie problem with POST vars

2002-06-13 Thread Remy Dufour

Put reset($_POST) before foreach loop

 I'm trying to loop through $_POST vars in a function, which I understand
to
 be an autoglobal associative array.  Here's the code I'm using:

 foreach($_POST as $item = $value){
 echo $item, $valuebr;
 }

 However, I only get the first element of the array echoed, even though I
 know there to be other elements (I can access them as $_POST[element])




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newbie problem with POST vars

2002-06-13 Thread Sear, Mick

I've tried this, but it's still doing the same thing.  Is there something
special about this particular variable that I need to know?  I've tried it
with $HTTP_POST_VARS as well, declaring $HTTP_POST_VARS as global in the
function first.

Put reset($_POST) before foreach loop

 I'm trying to loop through $_POST vars in a function, which I
understand
to
 be an autoglobal associative array.  Here's the code I'm using:

 foreach($_POST as $item = $value){
 echo $item, $valuebr;
 }

 However, I only get the first element of the array echoed, even
though I
 know there to be other elements (I can access them as
$_POST[element])




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newbie problem with POST vars

2002-06-13 Thread Jason Wong

On Thursday 13 June 2002 21:16, Sear, Mick wrote:
 I've tried this, but it's still doing the same thing.  Is there something
 special about this particular variable that I need to know?  I've tried it
 with $HTTP_POST_VARS as well, declaring $HTTP_POST_VARS as global in the
 function first.

   Put reset($_POST) before foreach loop

I'm trying to loop through $_POST vars in a function, which I

 understand
   to

be an autoglobal associative array.  Here's the code I'm using:
   
foreach($_POST as $item = $value){
echo $item, $valuebr;
}
   
However, I only get the first element of the array echoed, even

 though I

know there to be other elements (I can access them as

 $_POST[element])


What do you get if you do:

 print_r($_POST);



-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
I gave up Smoking, Drinking and Sex.  It was the most 
*__horrifying* 20
minutes of my life!
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Newbie problem with POST vars

2002-06-13 Thread Remy Dufour

If you do this, it should work

function foo()
{
global $_POST;
reset($_POST);
foreach($_POST as $item = $value){
echo $item, $valuebr;
}
}

Thats work for me.


 I've tried this, but it's still doing the same thing.  Is there something
 special about this particular variable that I need to know?  I've tried it
 with $HTTP_POST_VARS as well, declaring $HTTP_POST_VARS as global in the
 function first.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Newbie problem with POST vars

2002-06-13 Thread Ford, Mike [LSS]

 -Original Message-
 From: Remy Dufour [mailto:[EMAIL PROTECTED]]
 Sent: 13 June 2002 14:34
 
 If you do this, it should work
 
 function foo()
 {
 global $_POST;

That's unnecessary -- the $_ arrays are automatically global (superglobal).

 reset($_POST);

That's unnecessary -- foreach always traverses the whole of an array, regardless of 
the current position of its internal pointer.

 foreach($_POST as $item = $value){
 echo $item, $valuebr;
 }
 }

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Newbie problem with POST vars

2002-06-13 Thread Sear, Mick

print_r($_POST); shows all the elements in the array as I expect them to be.
That foreach loop is only picking the first element, though.  At least it's
reassured me that I'm not going mad, though, so thanks for that.

Mick

 I've tried this, but it's still doing the same thing.  Is there something
 special about this particular variable that I need to know?  I've tried it
 with $HTTP_POST_VARS as well, declaring $HTTP_POST_VARS as global in the
 function first.

   Put reset($_POST) before foreach loop

I'm trying to loop through $_POST vars in a function, which I

 understand
   to

be an autoglobal associative array.  Here's the code I'm using:
   
foreach($_POST as $item = $value){
echo $item, $valuebr;
}
   
However, I only get the first element of the array echoed, even

 though I

know there to be other elements (I can access them as

 $_POST[element])


What do you get if you do:

 print_r($_POST);



-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
I gave up Smoking, Drinking and Sex.  It was the most 
*__horrifying* 20
minutes of my life!
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php