I am having an issue - I am unable to get a td cell when my $v value is 0. For all other numbers it is fine, but with zero value I just don't get then td.. What could be wrong? I am using $_GET array with a foreach loop, taking data from two inputs, one for name, one for value.
<table border = "1" >
<?php
print_r($_GET);
foreach ($_GET as $k=>$v){
if($v){
if ($rowFinished) echo "<tr>";
if (preg_match("/{$inputVardas}/i", $k))
{
echo "<td>$v</td>";
$rowFinished = false;
}
else if (preg_match("/{$inputSkaicius}/i", $k) and is_numeric($v))
{
if ($v < 10)
{
$color="green";
}
else if ($v > 10)
{
$color="red";
}
else if( $v == 10){
$color="yellow";
}
echo "<td style='color: $color'>$v</td>";
$rowFinished = true;
}
if ($rowFinished) echo "</tr>";
}
}?></table>
I've tried to do some print_r of an array, there I can see a value, but in my loop it just doesn't work. Maybe it has to do something with the case that php treats it as empty, but I am unable to find a way to use it.
[vardas0] => jonas [value0] => 0