I would like to print only specific part from an Url like for example if i got on response an URL like this :
I want to print only this part exactly :
XRpC8tmn2_VUz6temt_j19BIGymiYyd5ZOLoWtp1H5U
I have tried to use substr like this :
$string=$headers['location'][0];
$substring = substr($string, strpos($string, '=') + 1);
// Use substr() again to get the part of the string before the semicolon
$final_string = substr($substring, 0, strpos($substring, ';'));
file_put_contents("xxx", $final_string);
$xtoken = file_get_contents("xxx");
but it's doesn't print nothing to my file xxx
but if I apply it like this only :
$string=$headers['location'][0];
file_put_contents("xxx", $string);
$xtoken = file_get_contents("xxx");
it print full line as I mentioned above .
Hope I find the right guide to be able to select & print only that specific part I want .
thank you .
session
parameter, is it the value first parameter regardless of which parameter it is, etc? Also you seem to be asking 2 questions here - Q1 is how to select the part you want and Q2 is how to write it to the file. Please note that each question on Stack Overflow should be one single question.// Use substr() again to get the part of the string before the semicolon
- what semicolon? There doesn't appear to be any in the example input value you have given.