> 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:";
Do you have anything else in _POST that's equal to 1? I didn't look up order of operation, so I may be off here, but your if condition might not be doing what you are expecting. Try using parentheses to group it like this if(ereg("color-", $ThisVar) AND ($ThisVal=="on" OR $ThisVal==1)){ (I'm guessing that's what you want). Why are you using ereg anyway? You're not using a regular expression so strstr would work just as well and be slightly faster. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php