PHP extracts the URL address of a Web site in a string by means of a string URL
This article describes how PHP extracts the URL address of a Web site in a string. Share to everyone for your reference. The specific analysis is as follows:
Today to write a question and answer system online after the discovery of a lot of people send links, because the business department wants us to filter out the site address, below I give you to share an extract string URL address function, the code is as follows:
Copy the code as follows: $postInfo [' answer2 '] = ' yes, commercial loans can be amortized 36%, Provident Fund loans can be amortized 16%| | | The balance of the account can be withdrawn to use as a down payment, and then the monthly loan business loans can be amortized 36%, Provident Fund loans can be amortized 16%| | | Yes, now a Provident fund is a amortization ratio http://www.bkjia.com is the wage base of the 34%| | | Ah ah ah ah ah ah oh yes | | | Can be amortized, a class 34%
';
Preg_match_all ("/http:[\/]{2}[a-z]+[.") {1} [a-z\d\-]+[.] {1} [a-z\d]*[\/]*[a-za-z\d]*[\/]*[a-za-z\d]*/", $postInfo [' Answer2 '], $array 2);
Print_r ($array 2);
if (!emptyempty ($array 2[0))
{
foreach ($array 2[0] as $k = = $v) {
$postInfo [' answer2 '] = Str_replace ($array 2[0][$k], ", $postInfo [' answer2 ']);
}
}
The result of the operation is:
Copy the Code Code as follows: (
[0] = = Array
(
[0] = http://www.bkjia.com
)
)
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/920983.html www.bkjia.com true http://www.bkjia.com/PHPjc/920983.html techarticle php extracts the URL address of a Web site in a string method, string URL This article describes the PHP method of extracting the URL address of a Web site in a string. Share to everyone for your reference. The specific analysis is as follows: ...