[eluser]dimaomni[/eluser]
I've tried test with simpler code
Code:
<?php
$a = array("1"=>'',"2"=>0,"3"=>4,"4"=>'',"5"=>NULL);
foreach ($a as $b) {
if (!$b)
{
echo "b ".$b."<br />";
}
}
?>
result
b
b 0
b
b
----------------------
Code:
$a = array("1"=>'',"2"=>0,"3"=>4,"4"=>'',"5"=>NULL);
foreach ($a as $b) {
if(!empty($b))
{
} else echo "b ".$b."<br />";
}
result
b
b 0
b
b
-------------------
Code:
<?php
$a = array("1"=>'',"2"=>0,"3"=>4,"4"=>'',"5"=>NULL);
foreach ($a as $b) {
if($b === 0)
{
echo "b ".$b."<br />";
}
}
?>
result
b 0
-----------------
Code:
<?php
$a = array("1"=>'',"2"=>0,"3"=>4,"4"=>'',"5"=>NULL);
foreach ($a as $b) {
if($b === 0 or $b>1 && $b<12)
{
echo "b ".$b."<br />";
}
}
?>
result
b 0
b 4
----------
lsat code works but in project still not work, I've asked a teacher and he gave solution:
Code:
if (preg_match("!^([0-9]|1[1-2])$!", $b)
)..
so it works everywhere.