Converting a number string to a number - Noob Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jclarke
Forum Newbie
Posts: 4
Joined: Wed Jun 21, 2006 3:43 am

Converting a number string to a number - Noob Question

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You can type cast it also...

Code: Select all

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