Question about the url intercepted by php from a string
Source: Internet
Author: User
Hello, the question of intercepting URLs from strings in php is: first, I won't use php, but I hope you can solve this problem for me, thank you very much for calling a string $ longurl from a php program. The result of $ longurlecho is www.csdn.net/123456<ahref=http://www. question about intercepting URLs from strings in php
Hello everyone. First of all, I don't know php, but I hope you can solve this problem for me. thank you very much.
I call a string $ longurl from a php program
The result of the $ longurl echo is
Www.csdn.net/123456click here
How can I intercept the section www.csdn.net/123456?
What's wrong with the shortened address? could you please help me check it out?
------ Solution --------------------
You cannot get the regular expression you want, and $ urlbd = '$ bb [0]'. you define $ urlbd as a string of $ bb [0 ].
You must use double quotation marks to replace the variables in the parsing with the following
Preg_match ("/] *>. * <\/a>/I", $ aa, $ bb );
$ Urlbd = $ bb [1];
------ Solution --------------------
Just now csdn has crashed again.
How can I intercept the section www.csdn.net/123456?
Click here from www.csdn.net/123456.
Extract www.csdn.net/123456?
If so, there are many methods to shorten the website. I don't know if there are any other Web sites. do this for the time being?
$ Str = 'www .csdn.net/123456 ';
Preg_match ('/^ ([a-z \ d \. \/] +) $ urlStr = $ match [1];
Echo $ urlStr;
Result
Www.csdn.net/123456
------ Solution --------------------
Www.csdn.net/123456click here
To intercept all the characters $ s1, use $ strArray = explode ("------ solution --------------------
I mean:
I call a string $ longurl from a php program
The result of the $ longurl echo is
Www.csdn.net/123456click here
Are the $ longurl strings in this rule {url address! If yes, you can use the php string separation function to separate it, and then return an array:
$ StrArray = explode ("print_r ($ strArray );
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.