How do I find these and other options:
<title itemprop="name">Title</title>
<title>Title</title>
with this
preg_match('/<title>([^>]*)<\/title>/si', $contents, $match );
Thanks!
If you want to get all the titles then you'll probably want to use preg_match_all
nd not preg_match
. You should also take into consideration that there might be extra data (such as attributes) right after the <title
. Lastly, your "greater-than" sign should be changed to a "greater-than" - you're looking until a new tag is begining.
Here's a working solution:
preg_match_all('/<title[^>]*>([^<]*)<\/title>/si', $contents, $match );