Reputation: 1144
I have a string tokenNo=12345&securityCode=111&name=Sam
How is it possible to extract the datas and store them into variables as below?
$tokenNo='12345';
$securityCode='111';
$name='Sam';
Please help
Upvotes: 4
Views: 96
Reputation: 4110
Use
parse_str()
$string = 'tokenNo=12345&securityCode=111&name=Sam';
parse_str($string);
echo $name."<br>";
echo $tokenNo."<br>";
echo $securityCode.;
Upvotes: 0
Reputation: 2707
Use parse_str:
$string = 'tokenNo=12345&securityCode=111&name=Sam';
parse_str($string);
echo $tokenNo;
echo $securityCode;
echo $name;
Or you can store the entire variables in one array:
$string = 'tokenNo=12345&securityCode=111&name=Sam';
parse_str($string, $array);
print_r($array);
Upvotes: 6