php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16684 parse error on foreach given array as $_REQUEST['list']
Submitted: 2002-04-18 12:17 UTC Modified: 2002-04-18 12:53 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: bob at mroczka dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.2.0 OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: bob at mroczka dot com
New email:
PHP Version: OS:

 

 [2002-04-18 12:17 UTC] bob at mroczka dot com
i would like to iterate over the array named $_REQUEST['list'] like this:

foreach($_REQUEST['list'] as $user) {
	if (strlen($user")>$max) die("too long");
}
error_log("gettype gives: ". gettype($_REQUEST['list']),0);

when php attempts to run this code I get this parse error in my apache log:

PHP Parse error:  parse error, unexpected '\"' in /var/www/htdocs/tmp.php on line 698

The message I write to the log about the type confirms that the variable is an array.

I am currently using 4.2.0rc4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-18 12:37 UTC] sander@php.net
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit http://www.php.net/support.php


 [2002-04-18 12:45 UTC] bob at mroczka dot com
This is not a support question.  I know there many ways
to iterate over an array.  I just wanted to alert you to the fact
there is a problem with the foreach construct in its
handling of multi-dimensional arrays.
 [2002-04-18 12:48 UTC] robert at webmotion dot com
> foreach($_REQUEST['list'] as $user) {
>         if (strlen($user")>$max) die("too long");
                          ^
                         ^^^
                        ^^^^^
                          I
                          I
                          I
                          I

Cheers,
Rob.
 [2002-04-18 12:53 UTC] sander@php.net
user error -> bogus
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 12:01:36 2025 UTC