0

If you have a url like this: rapidshare.com/#!download|value1|values|value3

and you know the numbers how can you extract the value 1 and the value 3

Is there a way to extract the values between the 2nd and 3rd | and 3rd and 4th |

Thanks!

4
  • 4
    It sounds like you are attempting to automate downloads from RapidShare, which would be against their Terms Of Use. Commented Feb 20, 2011 at 14:51
  • up vote for your assumption. However, no. But even if I did, I hate rapidshare lol. Commented Feb 20, 2011 at 15:07
  • is there a Python method for this? Commented Feb 20, 2011 at 15:10
  • docs.python.org/library/string.html#string.split Commented Feb 20, 2011 at 15:23

3 Answers 3

3
$array = explode('|', $url);

And use $array[$index];

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Forgot about the explode function!
0
$url =  'http://rapidshare.com/#!download|546l3|448704915|eu.heinelt.ifile_1.4.1-2_iphoneos-arm_fabius.deb|2915';
$urlparts = explode("|",$url);

will give you all the parts as array in $urlparts

Comments

0

Al of the above are 1 way of doing this, but if your script is always extracting data after your script name. as in: somepage.com/download.php?var1='val1'&var2='val2' the only relevant part for you is var1='val1'&var2='val2'

Luckily, PHP has a superglobal that can help. $_SERVER['QUERY_STRING'] . This way you can get an array of values, much cleaner and not have to worry that your explode seperator was being used on any other part of the URL.

$url = $_SERVER['REQUEST_URI'];
$values = explode("|", $url);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.