Say, I have a direct URL to a Twitter post, like
$url="http://twitter.com/#!/YourName/status/01234567890123456";
or
$url="http://twitter.com/YourName/status/01234567890123456";
Could you please advise the simplest way in PHP (regexp, i suppose) to extract YourName out of these strings that looks something like that:
$account= ??? (???,$url);
Thanks.
You can use a regular expression to do this.
Something along the lines of:
preg_match("/http:\/\/twitter.com\/(#!\/)?([^\/]*)/", $url, $matches);
var_dump($matches);
I have created a rubular here: http://rubular.com/r/YNw7PVSxqS
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.