Kerudo Posted December 1, 2005 Share Posted December 1, 2005 For example the Integer.parse(String str), in java, which turns a string into a number. I can't seem to find one, so I'm wondering if there even is one. Link to comment Share on other sites More sharing options...
Petrucho Posted December 2, 2005 Share Posted December 2, 2005 im not sure if i understood you. something like this: <?php$str = "hello world";$int_from_str = (int) $str;?> Link to comment Share on other sites More sharing options...
Jack McKalling Posted December 2, 2005 Share Posted December 2, 2005 What exactly do you want to do with the string? Almost everything you can think about to do with them, can be done in PHP :)Is sprintf() what you want? It formats any string to another string according to a pattern.Or do you mean changing the data type by settype()? Link to comment Share on other sites More sharing options...
Kerudo Posted December 7, 2005 Author Share Posted December 7, 2005 im not sure if i understood you. something like this:<?php$str = "hello world";$int_from_str = (int) $str;?> <{POST_SNAPBACK}> Oh I didn't realize you can cast in PHP lol. Anyway what I mean is to convert a str to a literal integer. So for example:$str = "123";$num = somefunction($str); //parse the string literal into an integer.$num = 123What exactly do you want to do with the string? Almost everything you can think about to do with them, can be done in PHP :)Is sprintf() what you want? It formats any string to another string according to a pattern.Or do you mean changing the data type by settype()?<{POST_SNAPBACK}> I'm not sure what this fuction does, I read the examples but did't really understand it heh. Link to comment Share on other sites More sharing options...
Jack McKalling Posted December 7, 2005 Share Posted December 7, 2005 I suppose settype() is what you're looking for.You want to change a "string" into an "integer". That would be: settype($string, "integer");(Nothing more nothing less ) Link to comment Share on other sites More sharing options...
Kerudo Posted December 10, 2005 Author Share Posted December 10, 2005 I suppose settype() is what you're looking for.You want to change a "string" into an "integer". That would be:(Nothing more nothing less )<{POST_SNAPBACK}> Sweet! Thanks Dan!I also found some code that someone wrote on the php.net website under the settype function. It converts strings to integers, but I'll use this 'official' function heh. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now