I need to parse a number that has 3 s.f. and 2 d.p. (e.g. 2.34). The first two numbers (1st and 2nd s.f.) are then multiplied by 10. The second number stays as it is. Thus, for the example above, $a = 23 and $b = 4. I was able to get code similar to below to work when it was not a function but I would like to be able to incorporate the code into a function. I would like to be able to get the value $a and the value $b out of the function (separately if possible) but I am having problems doing this. Any help would be much appreciated.
$z = 1.63;
function getcoordinates($conv) {
$z = number_format($conv, 2);
$z = (string)$z;
$a = substr($z,0,3)*10;
$b = substr($z,3,1);
$a = settype($a, "float");
$b = settype($b, "float");
return $a;
return $b;
}
Why can’t you just calculate the values the way you described?
As demonstrated here, you can use
array()to return multiple values. When you call the function, you can uselist()to put the values into separate variables: