how can i get only value of 'v' from the following url
http://www.youtube.com/watch?v=NMAYr709-9Y&feature=dir
i.e NMAYr709-9Y
with php

Recommended Answers

All 3 Replies

You can use a regular expression to capture the part of the url you need.

preg_match('#journal/[a-zA-Z0-9]+\-([a-zA-Z0-9]+)/#', $string, $matches);
$match = $matches[1];

how can i get only value of 'v' from the following url
http://www.youtube.com/watch?v=NMAYr709-9Y&feature=dir
i.e NMAYr709-9Y
with php

are u talking about GET parameters? If so, u can retrieve it from php as

$variable = $_GET['v'];

if u are trying to extract this from a random url, u will have to do some string manipulations... google for php string functions...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.