How to extract PHP array values and remove data -
i have seen bunch of ways, none seem work. array data coming this.
array ( [0] => result=0 [1] => respmsg=approved [2] => securetoken=8cpcwfzhah02qnliofegz1wo4 [3] => securetokenid=253cad735251571cebcea28e877f4fd7
i use this:
<?php echo $response[2];?>
too each out, works. need remove “securetoken=” im left number strings. have been trying out success.
function test($response){ $secure_token = $response[1]; $secure_token = substr($secure_token, -25); return $secure_token; }
also im putting end number form input “value” field. not that matters, unless does? thanks
this do:
$keyresponse = []; foreach ($response $item) { list($k, $v) = explode('=', $item, 2); $keyresponse[$k] = $v; }
now can access value part of each item based on name:
echo $keyresponse['securetoken']; // output: 8cpcwfzhah02qnliofegz1wo4
the advantage method code still works if order of items in $response
changes
Comments
Post a Comment