Help make preg_replace () which will reduce all the links to the word "spam")
Closed due to the fact that off-topic participants 0xdb , aleksandr barakin , freim , LFC , Andrew Goroshko March 17 at 7:56 .
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
- " Learning tasks are allowed as questions only on the condition that you tried to solve them yourself before asking a question . Please edit the question and indicate what caused you difficulties in solving the problem. For example, give the code you wrote, trying to solve the problem "- 0xdb, freim, LFC
- Sample text can be in the studio? - Manitikyl
- Come on example.com and win - Dmitry Tereshchuk
- Or just a link - Dmitry Tereshchuk
|
1 answer
$text = '123 https://ru.stackoverflow.com 123'; $pregr = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; echo preg_replace($pregr, "<SPAM>", $text);
- and what if we have after the link or there is nothing or any text) - Dmitry Tereshchuk
- @ DmitryTreshchuk so check first) and then say
что если
. Or you can give a specific example where it does not work. - Manitikyl - Slightly modernized and generally good)) - Dmitry Tereshchuk
|