tags:

views:

93

answers:

3

Hi,

This doesn't work:

list($value) = sscanf('foo.bar','%s.bar');
echo $value; //foo.bar

While this does:

list($value) = sscanf('foo bar','%s bar');
echo $value; //foo

Any suggestions are really appreciated. Thanks.

+2  A: 

I think it by design. It is trivial to use preg_match here, to be honest.

SilentGhost
Thank you, i'll go with preg_match()
+2  A: 

you can use explode instead of sscanf() for what you want to do.

$str = "foo.bar";
list($value1,$value2) = explode(".",$str);
print $value1;
ghostdog74
Unfortunately, this was just an simplified example and it's possible that multiple variables or characters occur.
+1  A: 

You can use a basic (negated) character class instead of s as in:

list($value) = sscanf('foo.bar','%[^.].bar');
echo $value; //foo
salathe