Optional & quot; & gt; dir & lt; a & gt; & quot; print_r (gethref ($ ss); & nbsp; & nbsp script ec (2); script
The Code is as follows: |
|
$ Ss = "dadfxxdir "; Print_r (gethref ($ ss )); Function gethref ($ temp ){ Preg_match_all ('/(. + ?)/Sim ', $ temp, $ ); Return $ a [1]; } |
// All the following a connections
The Code is as follows: |
|
$ Htm = preg_replace ("@ is", "$1", $ ss ); Print_r ($ htm ); |
// Completely extract the url Connection address
The Code is as follows: |
|
$ Url = "http://www.111cn.net "; $ Html = file_get_contents ($ url, "r "); Preg_match_all ("/(] *) (>) ([^ <] *) (<) ([^>] *) (>)/", $ html, $ matches ); For ($ I = 0; $ I { Echo "| ". $ matches [2] [$ I]. "| ". $ matches [3] [$ I]. $ matches [4] [$ I]. "| ". $ matches [6] [$ I]. "| ". $ matches [8] [$ I]." "; } |
// Extract all link addresses in the document string
The Code is as follows: |
|
Preg_match_all ('/(? <= Href = ") [wd.:/] */', $ str, $ fstr ); |