Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String to Numeric

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a function &getprice() that parsers a HTML document and returns a string (It is a cost of on item). Now I want to make it numeric for adding purposes. What do I do.

Here is how I reference it:
$price=getcost(9662,1,37160,32225);
$tot=$tot+$price

function getcost($id,$totlbs,$from,$to)
{
$page = fopen (" "r");
while (!feof ($page))
{
$line = fgets ($page, 15360);
if (eregi(&quot;<TD HEADERS='ROW2 HEADER3' align=right><font face='Arial'><B>&quot;, $line, $out))
{
return($line);
}
}
fclose($page);
return(0);
but it will not give me the correct answer. Is this because it is returning a string variable?
 
Generally, PHP treats variables how ever you treat them. So long as you do not have anything &quot;non-numerical&quot; being returned you should be fine.

Good Luck! -gerrygerry
Go To
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top