This article is an example of how PHP extracts a Web site URL address in a string. Share to everyone for your reference. The specific analysis is as follows:
Today, write a question and answer system online found that a lot of people sent links, because the business unit to filter out the site address, I would like to share a string to extract the URL address function, the code is as follows:
Copy Code code as follows:
$postInfo [' answer2 '] = ' can, commercial loans can be amortized 36%, Provident Fund loans can be amortized 16%| | | You can withdraw the balance in the account as a down payment, and then each month loans to the commercial loans can be amortized 36%, Provident Fund loans can be amortized 16%| | | Yes, now a Class A provident fund is the proportion of http://www.jb51.net is the wage base 34%| | Ah ah ah ah ah ah ah yes It can be amortized, 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 results of the operation are:
Copy Code code as follows:
(
[0] => Array
(
[0] => http://www.jb51.net
)
)
I hope this article will help you with your PHP program design.