NYCPHP Meetup

NYPHP.org

[nycphp-talk] problems with in_array

Chris Shiflett shiflett at php.net
Thu Jul 31 13:08:37 EDT 2003


I hope you don't mind if I rewrite your code a little bit to simplify it and
try to see if I understand the question correctly.

$get_array = array('foo', 'bar');
foreach ($_GET as $get_name => $get_val)
{
     $in_array = in_array($get_name, $get_array);
     echo "$get_name $in_array<br />";

     if (!in_array($get_name, $get_array))
     {
          $form_array[] = $get_name;
          echo "hidden form field for $get_name";
     }
}

So, you are saying that when you pass a URL variable named foo, you will see
output such as this:

foo 1<br />
hidden form field for foo

Right? If so, you're right that it doesn't make any sense, but I might be
misinterpreting your question.

Chris



More information about the talk mailing list