Bug in Ereg?
| From: | Kris Yates | Date: | Fri, 15 Aug 2003 21:53:15 +0000 |
| Subject: | Bug in Ereg? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-159765@lists.php.net to get a copy of this message | ||
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