'Difficulty skipping non-numeric values by retaining zero values in loop
I'm having some difficulty in skipping empty values in an array but retaining values of '0.000'.
I need to skip values which are genuinely blank (i.e. ' ' or '') but to not skip values which evaluate to zero, or 0.000.
Using == NULL doesn't seem to work as this skips a value of '0.000'.
I have tried using !is_numeric but again this is skipping the value of '0.000' - this one puzzles me more, as surely 0.000 is numeric?
The value passed to $res[$i]["timed"] comes from a MySQL query structured like SELECT race_id, ROUND((`time` + 0),3) AS `timed` FROM races.
For context, this is to detail the finishers of a race in terms of the margin of victory. So a value of 0.000 equates to a dead heat. I need to skip geninely blank values, as these exist where no data is available. As it stands, the races with no data are showing at the top of the results list. However, their margin of victory shows as blank, but the dead heat races do actually show '0.000' as the margin. In the example dataset below, I want to skip the first seven rows but retain the eighth row from the margin column.
if($res[$i]["timed"] !== NULL && !is_numeric($res[$i]["timed"])) {$i++; continue;}
Using =, == or === does not get around this issue - the value of '0.000' appears to fall between the arguments.
Here is a link (https://www.touringcars.net/database/so-72038612.php) to the page with a var_dump showing the eighth entry has a string(5) of "0.000". Yet even by querying on strings with a length of at least 5, the "0.000" still does not show.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

