Use parse_str()
parse_str(str_replace(';','&',$yourresultfromURL),$matcharray);
Explanation :
Replacing ;
by &
inorder to bring that to parse_str
format and finally those matches are moved to $matcharray
array.
Question
Hi I am using maxmind minfraud. And I got the result like this:
err=;countryCode=IN;ip_region=25;ip_city=;ip_latitude=10.0223;ip_longitude=30.2433;highRiskCountry=No;queriesRemaining=1075;cityPostalMatch=;shipCityPostalMatch=;ip_domain=;ip_countryName=;ip_continentCode=AS;ip_corporateProxy=No;shipForward=NA;riskScore=0.20;prepaid=;minfraud_version=1.3
Here I want to return as array value.
<?php
function fraudQuery($ip, $country_code, $state, $city, $area_code, $mail_domain,$address)
{
$d = file_get_contents("https://minfraud.maxmind.com/app/ccv2r?license_key=".IP_LOOKUP_KEY."&i=$ip&country=$country_code&city=$city&postal=$area_code&domain=$mail_domain&shipAddr=$address&shipCity=$city&shipRegion=$state&shipPostal=$area_code&shipCountry=$country_code");
return array('Errors' =>err, 'IpCountryCode' => countryCode, 'IpCountry' => ip_countryName, 'IpRegionCode' => ip_region, 'IpRegion' => ip_regionName, 'IpCity' => ip_city, 'IpHostName' => ip_domain, 'Score' => riskScore);
}
?>
How to return as array value like this. Thanks
Solution
Use parse_str()
parse_str(str_replace(';','&',$yourresultfromURL),$matcharray);
Replacing ;
by &
inorder to bring that to parse_str
format and finally those matches are moved to $matcharray
array.