Is it possible to parse an HTML file in PHP to extract all <a href tags and save them in a two-dimensional array?

To parse an HTML file in PHP and extract all <a href> tags, you can use the PHP Simple HTML DOM Parser library. This library allows you to easily manipulate HTML elements using jQuery-like syntax. You can loop through all <a> tags in the HTML file, extract the href attribute, and save them in a two-dimensional array.

&lt;?php
include(&#039;simple_html_dom.php&#039;);

$html = file_get_html(&#039;example.html&#039;);

$links = array();

foreach($html-&gt;find(&#039;a&#039;) as $element){
    $link = array(
        &#039;href&#039; =&gt; $element-&gt;href,
        &#039;text&#039; =&gt; $element-&gt;plaintext
    );
    $links[] = $link;
}

print_r($links);
?&gt;