If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

cast string to float in php

Hi Everyone,

I'm trying to use a math equation ( see bottom of post) to get the distance of two points. I am able to get the data from the user and the server. However, when I try to use the equation, NAN(not a number) is displayed. I tried to resolve this issue by casting the variables to (float) but this did not work either. I'm not sure what is off here. Can you take a look?

PHP Code:

// get user input
$userLong=(float)$_POST['userLong']=-73.9599609375;

$userLat=(float)$_POST['userLat']=40.8169272319157;

[/PHP]

PHP Code:

//data was supplied from the server in the while loop. Use foreach loop to parse data for getDistance function

Found Carmon Santdiago? Waldo? Michael Westen? NO? But I found the answer!. php function acros() returns NAN if the number is between 1 and infinity. This function only works with fractions ( in this case decimals). I snooped around and found another function on this site http://www.zipcodeworld.com/samples/distance.php.html