I have the following code in an html form
The form is then posted to an php function which does the following
The above returns incorrect results for the following input
prints the following
Can someone please tell me how to fix this problem whereby a 0 is returned when an input field is empty and of preventing the numbers from being converted to integers. I tried to check if the value is 0 and not consider this but this results in a problem if the value typed in is 0.
Code:
<input type="text" name = 'ions[1]'> <input type="text" name = 'ions[2]'> <input type="text" name = 'ions[3]'>
Code:
foreach($ions as $ion_id => $value){
echo $ion_id . " " . $value;
}
Code:
ions[1] = ""; ions[2] = "12.34"; ions[3] = "3";
1 0
2 12
3 3
Can someone please tell me how to fix this problem whereby a 0 is returned when an input field is empty and of preventing the numbers from being converted to integers. I tried to check if the value is 0 and not consider this but this results in a problem if the value typed in is 0.
Comment