Jump to content

Is there a funciton to parse strings?


Kerudo

Recommended Posts

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

im not sure if i understood you. something like this:
<?php$str = "hello world";$int_from_str = (int) $str;?>

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 = 123
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()?

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

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 :))

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...