Re: Last array element not found

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 15/03/06, Roman Rumisek <romanr@xxxxxxx> wrote:> Hi,>> this code fragment give following result in my error log:>> foreach($reg_array as $region_item)>   $tmp_reg_array[] = $region_item[0];> $sel_region = explode(',', $_POST[CLIENT_REGION]);> foreach($sel_region as $sel_region_item)>   if(!in_array($sel_region_item, $tmp_reg_array))>   {>     my_error_log("Unknown region: $sel_region_item, region array: ".>                  var_export($tmp_reg_array, TRUE));>     header("Location: ".>       get_error_result(>          $state_def[$_SESSION[STATE_VAR]][STATE_REDIR_PAGE])>     );>     exit;>   }
It's more likely that you've got whitespace before or after theregion, especially if it's the last in the list that's always failing. Try trimming the region before passing it to in_array().
Have you ever considered using braces around loop blocks?
  -robin

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux