- urldecode: documentation ( source)
- print_r: documentation ( source)
- explode: documentation ( source)
- strtolower: documentation ( source)
<?php
function postLikeStrToArray($str)
{
$_p = explode('&', $str);
$post = [];
foreach ($_p as $item) {
$parts = explode('=', $item);
$key = strtolower($parts[0]);
$value = urldecode($parts[1]);
$post[$key] = $value;
}
return $post;
}
$resp = "MerID=I0110DQX&OrderID=191&ResponseCode=3&ReasonCode=11&ReasonCodeDesc=Invalid+signature&Signature=hHxm7Zd1GeUJz3ZfkloaNG%2BC1hk%3D";
$post = postLikeStrToArray($resp);
print_r($post);