On Saturday 07 February 2004 23:56, Sebastian wrote: > Is there a possibility to convert a string like "10*500" (parsed from a > XML-File) to a float? > When i try to store this String in a float variable it only coverts the > "10" but nothing after the "*"-sign, but i need the result of this > expresison... Is there a function to calculate such string expressions?
Not sure if there is a more elegant way but: $doo = "10*500"; eval('$dah = ' . $doo . ';'); echo $dah; -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ /* "Necessity is the mother of invention" is a silly proverb. "Necessity is the mother of futile dodges" is much nearer the truth. -- Alfred North Whitehead */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php