Get number in html code

i have the following html…

<a href=“page1.htm”><span class=“pagelink”>1</span></a>

<span class=“pagelink”>2</span>

<a href=“page3.htm”><span class=“wp-pagelink”>3</span></a>

How can I get the number 2 with php?


$html = 
'<a href="page1.htm"><span class="pagelink">1</span></a>

<span class="pagelink">2</span>

<a href="page3.htm"><span class="wp-pagelink">3</span></a>';

$matches = array();
preg_match_all('/<span\\sclass="pagelink">(.*?)<\\/span>/',$html,$matches);
echo '<pre>',print_r($matches),'</pre>';

to do what?

php is executed on the server before the html is sent to the user’s browser.

html is executed in the user’s browser after all the php code has been executed on the server.