[thelist] [PHP] variable conversion tip

Paul Bennett paul at teltest.com
Thu Nov 6 17:16:15 CST 2003


<tip type="PHP and string->number conversion">
Having trouble getting PHP to treat string data (POST or GET) as a 
number for a script calculation?

Multiply the data you are using in calculation by 1 and then use it - 
this seems to tell PHP to treat the data as numeric

# sample code
$duration_in_seconds = ($HTTP_POST_VARS['p_duration'] * 1) * 60;

:)
</tip>

Paul Bennett
Visit
http://www.clicksave.co.nz
For your free report: 
"10 time-killing web development mistakes and how to avoid them"
		




More information about the thelist mailing list