What regex code can i use to find an html tag, and then extract the string out of it?
<?php
$html = "<span class="equipped">360</span>"
$match = preg_match("???", $html, $matches);
?>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As npinti points out, you shouldn’t use a regular expression to parse a non-regular language. Instead, you can use PHP’s DOMDocument to find the text of any node you want. Here’s an example for capturing the
<span>element’s inner text and a demonstration to show how it works.Demo
Edit: My example shows using a semi-complete HTML document, but DOMDocument will also successfully parse an HTML string such as
$html = '<span>Text</span>';, see here.