oshirowanen
oshirowanen

Reputation: 15965

Extracting a certain section of a string

How do I get the value of tracking_id from a string similar to the string below:

action_type=PAY&transaction_type=Adaptive+Payment+PAY&tracking_id=bovxedxgM&status=COMPLETED&

That is just a snipped of a much longer string.

Upvotes: 0

Views: 46

Answers (2)

KingCrunch
KingCrunch

Reputation: 132071

$arguments = array();
parse_str('action_type=PAY&transaction_type=Adaptive+Payment+PAY&tracking_id=bovxedxgM&status=COMPLETED', $arguments);
$tracking_id = $arguments['tracking_id'];

http://php.net/parse-str

Upvotes: 0

ThiefMaster
ThiefMaster

Reputation: 318778

Use parse_str():

parse_str('your-string-here', $data);
echo $data['tracking_id'];

Upvotes: 4

Related Questions