Re: Bug in Ereg?

From: Date: Fri, 15 Aug 2003 22:00:04 +0000
Subject: Re: Bug in Ereg?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-159766@lists.php.net to get a copy of this message
Just an addendum.. My parser has $colors=""; right before the foreach loop. Kris Yates wrote:
Hi, I have a form with checkboxes that POSTs to a PHP script. What is posted [ from phpinfo() ]:
_POST["color-1"]     on
_POST["color-4"]     on
_POST["color-6"]     on
Parser: foreach($_POST as $ThisVar=>$ThisVal){
       if(ereg("color-", $ThisVar) AND $ThisVal=="on" OR $ThisVal==1){
           $newVarA=explode("-", $ThisVar);
           $colors.="$newVarA[1]:";
           }
       }
Expected Output: $colors="1:4:6:"; Real Output: $colors=":1:4:6:"; I can work with the output I am getting, however, I am curious why I am not getting the "expected output". Can anyone shed light on this? I am using PHP 4.3.2 compiled under a unix environment. Is this a bug in ereg or am I just not seeing something obvious in my foreach? Thanks, Kris


« previous php.general (#159766) next »