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.
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.
I think it by design. It is trivial to use preg_match
here, to be honest.
you can use explode instead of sscanf() for what you want to do.
$str = "foo.bar";
list($value1,$value2) = explode(".",$str);
print $value1;
You can use a basic (negated) character class instead of s
as in:
list($value) = sscanf('foo.bar','%[^.].bar');
echo $value; //foo