A little confused about sscanf() and formatting.
Posted: Mon Mar 05, 2007 6:09 pm
feyd | Please use
The output is:
int(32) string(25) "wolf>canine>mammal>animal" NULL NULL NULL
But I would like "wolf" "canine" "mammal" and "animal" to be separated into the $v2,$v3,$v4 and $v5 variables.
I'm sure I'm missing a basic concept of format characters. Can anyone
assist me? Thanks very much!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have looked at some examples for sscanf, but I can't tell what I'm doing wrong.Code: Select all
$c=">32>wolf>canine>mammal>animal";
sscanf($c,'>%d>%s>%s>%s>%s', $v1,$v2,$v3,$v4,$v5);
var_dump($v1,$v2,$v3,$v4,$v5);int(32) string(25) "wolf>canine>mammal>animal" NULL NULL NULL
But I would like "wolf" "canine" "mammal" and "animal" to be separated into the $v2,$v3,$v4 and $v5 variables.
I'm sure I'm missing a basic concept of format characters. Can anyone
assist me? Thanks very much!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]