Page 1 of 1

Converting a number string to a number - Noob Question

Posted: Sun Aug 13, 2006 8:06 pm
by jclarke
I know it's definitlyy possible to do this.

I have a string that contains a number I want to convert it from a string to a number.

I've done this in javascript with parseInt/parseFloat.

Can anyone tell me the syntax to do that?

Thanks

Posted: Sun Aug 13, 2006 8:10 pm
by feyd

Posted: Sun Aug 13, 2006 8:13 pm
by RobertGonzalez
You can type cast it also...

Code: Select all

<?php
$mystring = '4.54';
$myint = (int) $mystring;
?>