|
I’m developing a PHP script that grabs
the contents of a web page, strips out all the tags, parses the contents for
information I want, and puts that information into variables I can manipulate. There
are certain keywords that remain fixed, but the associated values with each are
dynamic. I’m using sscanf() to try and find the keyword and put the associated value
into a variable. However, I need to use a wildcard to find what I want, but I
don’t know what the wildcard syntax is. It needs to accommodate all
possible characters, numbers, punctuation, etc. Here’s a simplified example: <?php $string=”My favorite color is: RED My dog’s name is: Rex My favorite food is: bacon My
favorite number is: 665 more junk goes here”; $n = sscanf($string, “My favorite color is: %s”, &$color); $n = sscanf($string, “My dog’s name is: %s”, &$dog); $n = sscanf($string, “My favorite food is: %s”, &$food); $n = sscanf($string, “My favorite number is: %d”,
&$number); ?> I don’t think word/character position
string functions would work in my actual code. Anyone? |
- Re: [bits] PHP sscanf() wildcard? Gregg Giles
- Re: [bits] PHP sscanf() wildcard? tack
- Re: [bits] PHP sscanf() wildcard? Erik Curiel
