我想找到所有A Href并获取他们的链接及其完整内容

my problem is that, i want to get this Content from a large HTML Code: All other Tags containing an href Tag should not be visible!

<a href="/admin/home" torero-icon="home">Home</a>

Here i want to get first of all "/admin/home" and as second the Whole a Tag "< a href="/admin/home" torero-icon="home">Home"

<a href="#" torero-icon="add" torero-left-icon="accessibility">Account Verwaltung</a>

Here i want to get first of all "#" and as second the Whole a Tag "< a href="#" torero-icon="add" torero-left-icon="accessibility">Account Verwaltung"

Thanks for your Help guys :)

I found something which did the Trick:

 preg_match_all('<a href="(.*)" (.*)>',$text,$match);

Resulted to:

Array
 (
  [0] => Array
    (
        [0] => a href="/redirect/torero::external/https[dd][s][s]www[d]google[d]de[s]/8CF0-6416-DAEF-8C2B-1819" torero-modified="link-leading-external">Google
        [1] => a href="/admin/home" torero-icon="home">Home
        [2] => a href="/admin/pages" torero-icon="pages">Seiten
        [3] => a href="#" torero-icon="add" torero-left-icon="accessibility">Account Verwaltung
        [4] => a href="/admin/accounts/users" torero-icon="person">Benutzer
        [5] => a href="/admin/accounts/permissions" torero-icon="check">Rechte
        [6] => a href="#" torero-icon="add" torero-left-icon="trending_up">Statistiken
        [7] => a href="/admin/statistics/trending" torero-icon="timeline">Beliebte Beiträge
        [8] => a href="/admin/statistics/visibility" torero-icon="visibility">SEO Statistiken
        [9] => a href="/admin/layouts" torero-icon="view_quilt">Layouts
        [10] => a href="#" torero-icon="add" torero-left-icon="settings">Einstellungen
        [11] => a href="/admin/settings/profile" torero-icon="person_pin">Profil
        [12] => a href="/admin/settings/extensions" torero-icon="extension">Erweiterungen
        [13] => a href="/admin/settings/updates" torero-icon="refresh">Software Updates
        [14] => a href="/admin/settings/info" torero-icon="info">System Info
        [15] => a href="/admin/settings/report" torero-icon="bug_report">Fehler melden
        [16] => a href="/admin/settings/feedback" torero-icon="feedback">Feedback geben
        [17] => a href="/admin/logout" torero-icon="exit_to_app">Abmelden
    )

[1] => Array
    (
        [0] => /redirect/torero::external/https[dd][s][s]www[d]google[d]de[s]/8CF0-6416-DAEF-8C2B-1819
        [1] => /admin/home
        [2] => /admin/pages
        [3] => #" torero-icon="add
        [4] => /admin/accounts/users
        [5] => /admin/accounts/permissions
        [6] => #" torero-icon="add
        [7] => /admin/statistics/trending
        [8] => /admin/statistics/visibility
        [9] => /admin/layouts
        [10] => #" torero-icon="add
        [11] => /admin/settings/profile
        [12] => /admin/settings/extensions
        [13] => /admin/settings/updates
        [14] => /admin/settings/info
        [15] => /admin/settings/report
        [16] => /admin/settings/feedback
        [17] => /admin/logout
    )

[2] => Array
    (
        [0] => torero-modified="link-leading-external">Google
        [1] => torero-icon="home">Home
        [2] => torero-icon="pages">Seiten
        [3] => torero-left-icon="accessibility">Account Verwaltung
        [4] => torero-icon="person">Benutzer
        [5] => torero-icon="check">Rechte
        [6] => torero-left-icon="trending_up">Statistiken
        [7] => torero-icon="timeline">Beliebte Beiträge
        [8] => torero-icon="visibility">SEO Statistiken
        [9] => torero-icon="view_quilt">Layouts
        [10] => torero-left-icon="settings">Einstellungen
        [11] => torero-icon="person_pin">Profil
        [12] => torero-icon="extension">Erweiterungen
        [13] => torero-icon="refresh">Software Updates
        [14] => torero-icon="info">System Info
        [15] => torero-icon="bug_report">Fehler melden
        [16] => torero-icon="feedback">Feedback geben
        [17] => torero-icon="exit_to_app">Abmelden
    )

)

I'm working on something similar:

$urls = preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $page, $urls);

This will get all URLS, but to get all hrefs you'll need to change the regular expression used with one to fine what you want.

you can then use a foreach statement to loop through the results:

foreach ($urls as $url){
    echo "url: " . $url;
}

If it's a simple string, then use strstr or preg_match_all. If you have an entire HTML document, use PHP's builtin DOMDocument. Consider:

$page_html = "<!DOCTYPE html>
<html>
...</body>
</html>";
$doc = \DOMDocument::loadHTML( $page_html );

$anchors = $doc->getElementsByTagName('a');
foreach ( $anchors as $a )
    echo "Anchor HREF: " . $a->getAttribute('href') . PHP_EOL;

Without proper tokenization, the string-based methods will miss edge cases. For example, how do you want to handle commented out anchors? Or how about anchors that do not quite follow the form you expect? The DOMDocument parser should catch exactly what you want.