Jump to content

Recommended Posts

Again not to confident with php I am trying to get a specific part of a url for example

 

http://www.pgrevents.co.uk/process/yvideo.php?catch=http://uk.video.yahoo.com/watch/5005027/13315673

 

I need to get the 5005027

 

Does anyone have any ideas? I tried looking for examples but I cant seem to get any

 

thanks

 

Paul

Link to comment
https://forums.phpfreaks.com/topic/156938-solved-url-stripping/
Share on other sites

First, I would advice you to learn PHP basics if you don't know it already. I am not underestimating your abilities, but it would help you to understand my code. It's a basic *snippet*. It's not a full code so please do not badger me about it not working if you just copy and paste.

 

<?php

$catch = $_GET['catch'];
preg_match('#watch/(\d+)/', $catch, $match);

Link to comment
https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826692
Share on other sites

First, I would advice you to learn PHP basics if you don't know it already. I am not underestimating your abilities, but it would help you to understand my code. It's a basic *snippet*. It's not a full code so please do not badger me about it not working if you just copy and paste.

 

<?php

$catch = $_GET['catch'];
preg_match('#watch/(\d+)/', $catch, $match);

 

Whoops, my mistake.

 

<?php

$catch = $_GET['catch'];
preg_match('#watch/(\d+)/#', $catch, $match);

 

I forgot the closing delimiter. I apologize. The above should be correct.

Link to comment
https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826705
Share on other sites

I have actualy been looking into this using parse_url here is an example

<?php
$catch = $_GET['catch'];
print $catch;
print "<br />";

///GO GO GADGET

print_r(parse_url($catch));
print "<br />";
echo parse_url($catch, PHP_URL_PATH); ?>

 

which gives me an out put of;

 

http://uk.video.yahoo.com/watch/5005027/13315673

Array ( [scheme] => http [host] => uk.video.yahoo.com [path] => /watch/5005027/13315673 )

-> this is using the last echo in the code = /watch/5005027/13315673

 

that is getting closer to what I am looking for. Am I on the right track?

 

thanks

 

Link to comment
https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826772
Share on other sites

That's not what I meant. It's just some people show less courtesy to people giving help that when I post snippets (not full code), they copy and pasted and then come back and say it doesn't work.

 

<?php

$catch = $_GET['catch'];
preg_match('#/watch/(\d+)/#', $catch, $match);

 

In that code, you would like to print_r($match) because it is an array. If you echo it, you'll get Array().

Link to comment
https://forums.phpfreaks.com/topic/156938-solved-url-stripping/#findComment-826796
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.