Kundan
Kundan

Reputation: 99

Explode Between Character PHP

$url = $_GET['url'];

// gets $url = http://www.facebook.com/UsedID

I want to explode url and get UserID only.

$userid = "UsedID";

echo "http://graph.facebook.com/$userid/picture ||";

I just Want to get The User Id.

Upvotes: 0

Views: 109

Answers (4)

Ranjan
Ranjan

Reputation: 263

$arr = explode('/', $url);
$userId = array_pop($arr);

Upvotes: 1

Amal
Amal

Reputation: 76646

$url = "http://www.facebook.com/UsedID";
$url = parse_url($url);
echo substr($url['path'], 1); //output: UsedID

Upvotes: 3

Code Lღver
Code Lღver

Reputation: 15593

Use this code:

$arr = explode("/", $url);
echo end($arr);

it will return the userid that is in the last of url.

Upvotes: 0

M Shahzad Khan
M Shahzad Khan

Reputation: 935

$user = explode("/",$url);
$userid = $user[count($user)-1];

Upvotes: 0

Related Questions