Jump to content


Photo

Basic preg_match question


  • Please log in to reply
3 replies to this topic

#1 All4172

All4172
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 13 July 2006 - 06:18 PM

Normally when I want to pull info out I would do something like:

preg_match('!<meta name="name" content="(.*?)"/>!is', $contents, $meta);

That would pull anything out between content="someinfo goes here"/>

This time I'm attempting to say, if anything at all is between the quotes in content=" ">, then do this.  How would I test that something is between the quotes?



#2 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 13 July 2006 - 06:23 PM

if $meta != "" {
//do stuff
}


#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 13 July 2006 - 06:24 PM

Use an if:
if(preg_match('!<meta name="name" content="(.*?)"/>!is', $contents, $meta))
{
    echo "A match was found!<br /><pre>" . print_r($meta, true) . "</pre>";
}
else
{
    echo "Now matchs found";
}


#4 All4172

All4172
  • Members
  • PipPipPip
  • Advanced Member
  • 78 posts

Posted 13 July 2006 - 06:27 PM

Wow, too simple LOL  Thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users