从单个数组中分离参数

时间:2015-12-03 15:20:35

标签: php arrays codeigniter

这是我的单长度数组

array(1) { ["http://abc_cde_com/riseres_php?TransactionID=2517055&Amount=1_00&AuthorizationCode=MB0118&ResultID=0&ResultMessage=APPROVED_OR_COMPLETED_SUCCESSFULLY_&ResponseCode=00&ResponseMessage=OPERATION_IS_APPROVED_(SIM)&HostResponseMsg=OPERATION_IS_APPROVED_(SIM)&ReferenceNumber=XYZ123&3DProvider=___"] => string(0) "" } 

如何从上面的数组和其他数组中获取TransactionID和ReferenceNumber?

1 个答案:

答案 0 :(得分:0)

使用parse_urlparse_str将$ _GET参数转换为assoc数组。像这样(假设你的数组被称为$input

$parsed = parse_url(current($input));
parse_str($parsed['query'], $params);
$transactionID = $params['TransactionID'];
$referenceNumber = $params['ReferenceNumber']