Kerudo 0 Posted December 1, 2005 Report 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. Quote Link to post Share on other sites
Petrucho 2 Posted December 2, 2005 Report Share Posted December 2, 2005 im not sure if i understood you. something like this: <?php$str = "hello world";$int_from_str = (int) $str;?> Quote Link to post Share on other sites
Jack McKalling 2 Posted December 2, 2005 Report 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()? Quote Link to post Share on other sites
Kerudo 0 Posted December 7, 2005 Author Report 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. Quote Link to post Share on other sites
Jack McKalling 2 Posted December 7, 2005 Report 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 ) Quote Link to post Share on other sites
Kerudo 0 Posted December 10, 2005 Author Report 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. Quote Link to post Share on other sites
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.