woody79 Posted June 20, 2007 Share Posted June 20, 2007 this is a string: $number = "9"; this is a number: $number = 9; I need to get a string into a number because i am grabbing the number using the GET funtion Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 20, 2007 Share Posted June 20, 2007 so add a varable to the get. <?php $number=$_GET['the_number']; echo $number; ?> $number holds 9 Quote Link to comment Share on other sites More sharing options...
chigley Posted June 20, 2007 Share Posted June 20, 2007 <?php $number = "9"; $number = intval($number); // $number = 9; ?> Quote Link to comment Share on other sites More sharing options...
woody79 Posted June 24, 2007 Author Share Posted June 24, 2007 Okay, <?php $number = "9"; $number = intval($number); // $number = 9; ?> that didn't work and i tried intval like this $number = intval($_GET['myNumber']); echo $number; $number++; $number did not increment Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 24, 2007 Share Posted June 24, 2007 thats because you incremented number after oyu echoed it Quote Link to comment Share on other sites More sharing options...
JustinK101 Posted June 24, 2007 Share Posted June 24, 2007 You might be able to do this as well: $number = (int)$_GET['myNumber']; $number++; echo $number; Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted June 24, 2007 Share Posted June 24, 2007 i think there is a difference in what is an int and whats a string in php 4/5 Quote Link to comment Share on other sites More sharing options...
JustinK101 Posted June 24, 2007 Share Posted June 24, 2007 I think it works either way. I just tested incrementing a string with 12 in it, and it worked. Quote Link to comment Share on other sites More sharing options...
woody79 Posted June 24, 2007 Author Share Posted June 24, 2007 thanks JustinK101, I forgot to mention i was using it in a loop Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.