PHP extract string in the URL address of the site method, string url_php tutorial

Source: Internet
Author: User

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: ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.