Currently I have the following code.
$file_id = 'https://skyvault.co/show/file?filename=6N2viQpwLKBIA6';
$parts = parse_url($file_id);
$path_parts = explode('/', $parts[path]);
$secret = $path_parts[3];
print $secret;
Above you can see that I am trying to explode by / and it's not returning the output I am looking for it's just returning file and I need it to return 6N2viQpwLKBIA6 so how could I get that ID?
parse_url works but you need to specify the query index. Redo it like this:
$file_id = 'https://skyvault.co/show/file?filename=6N2viQpwLKBIA6';
$parts = parse_url($file_id);
$path_parts = explode('=', $parts['query']);
$secret = $path_parts[1];
print $secret;
Is it possible for you to do it quickly this way, if the URL is always same for all the items?
$URLComp = explode("show/file?filename=", $file_id);
$secret = $URLComp[1];
print $secret;
The main reason is, there could be cases of with or without www, then with or without https.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With