$GET query to directory?

73 Views Asked by At

i want to fetch youtube videos from the above script but the above code is getting keyword from GET parameter example.com/s=keyword and i want it to get from a example.com/HERE i mean you can see there is a $_GET['s'] So this function works like this

example.com/s=keyword

and i want it to work like this

example/page/keyword

sorry for my bad english

$keyword = $_GET['s'];
file_get_contents("https://www.googleapis.com/youtube/v3/search?part=snippet&q=$keyword&type=video&key=abcdefg&maxResults=5");
1

There are 1 best solutions below

0
On BEST ANSWER

Have a look at $_SERVER[REQUEST_URI] This will return you the current url. Then process it using simple string or array functions to get the params, like

$current_url = $_SERVER['REQUEST_URI'];
$url_arr     = explode("/", $current_url);

Then access the parameters using the array indexes like $page = $url_arr[0];