Page 1 of 1

How do I conert a string to a number?

Posted: Thu May 22, 2003 12:16 pm
by Winter
hello..

Would you please tell me how do I convert a string to a number (integer)?

Thank you..


Winter :oops:

Posted: Thu May 22, 2003 12:29 pm
by liljester

Code: Select all

<?php
$my_int = intval($my_var);
?>

Posted: Fri May 23, 2003 1:58 am
by twigletmac
PHP is loosely typed so depending on what you are trying to do it's probably not neccessary to change the type of the variable.

Mac

Posted: Fri May 23, 2003 10:35 am
by liljester
unless there is a comma or somesuch in the varialbe, and you just want the numeric value of the contents of the variable =)