4

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

0

3 Answers 3

6

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);
Sign up to request clarification or add additional context in comments.

Comments

0
parse_str($string, $array);
print_r($array);

Comments

0

Use

parse_str()

$string = 'tokenNo=12345&securityCode=111&name=Sam';
parse_str($string);
echo $name."<br>";
echo $tokenNo."<br>";
echo $securityCode.;

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.