Jump to content

Archived

This topic is now archived and is closed to further replies.

All4172

Basic preg_match question

Recommended Posts

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

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

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?

Share this post


Link to post
Share on other sites
Use an if:
[code=php:0]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";
}[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.