Page 1 of 1

sscanf() ?

Posted: Sat Feb 09, 2008 12:05 am
by Chris Corbyn
I'm not an expert on the whole behaviour of printf() and friends, but should I give up trying to achieve this?

Code: Select all

list ($type, $value) = sscanf("string:foobar", "%s:%s");
$value is always NULL and $type is the entire string, including the colon :(

I'm currently using substr() but spotted this cool looking function in the manual. Will it always be too greedy?

Re: sscanf() ?

Posted: Sat Feb 09, 2008 12:17 am
by Chris Corbyn
Answered my own question :P

Code: Select all

list($type, $value) = sscanf($string, "%[^:]:%s");