我有一个JSON字符串,我想只获得第一个域名,即使用PHP显示它的键。 JSON字符串如下。
{"mysite.co":{"status":"available","in_ga":"true","score":"0.73","spin":"no"},"mysite.ooo":{"status":"available","in_ga":"true","score":"0.6","spin":"no"},"my-site.website":{"status":"available","in_ga":"true","score":"0.57","spin":"yes"},"ratemysite.website":{"status":"available","in_ga":"true","score":"0.568","spin":"yes"},"findmysite.website":{"status":"available","in_ga":"true","score":"0.557","spin":"yes"},"sellmysite.website":{"status":"available","in_ga":"true","score":"0.545","spin":"yes"},"rate-my-site.com":{"status":"available","in_ga":"true","score":"0.491","spin":"yes"},"my-domain.website":{"status":"available","in_ga":"true","score":"0.48","spin":"yes"},"ratemydomain.website":{"status":"available","in_ga":"true","score":"0.477","spin":"yes"},"findmydomain.website":{"status":"available","in_ga":"true","score":"0.466","spin":"yes"},"my-place.website":{"status":"available","in_ga":"true","score":"0.457","spin":"yes"},"sellmydomain.website":{"status":"available","in_ga":"true","score":"0.455","spin":"yes"},"myjobsite.website":{"status":"available","in_ga":"true","score":"0.455","spin":"yes"},"ratemyplace.website":{"status":"available","in_ga":"true","score":"0.455","spin":"yes"},"ratemysitegroup.com":{"status":"available","in_ga":"true","score":"0.451","spin":"yes"},"ratemysiteonline.com":{"status":"available","in_ga":"true","score":"0.451","spin":"yes"},"ratemysiteshop.com":{"status":"available","in_ga":"true","score":"0.451","spin":"yes"},"findmyplace.website":{"status":"available","in_ga":"true","score":"0.443","spin":"yes"},"sellmysite.org":{"status":"available","in_ga":"true","score":"0.442","spin":"yes"},"findmysitegroup.com":{"status":"available","in_ga":"true","score":"0.441","spin":"yes"},"findmysiteonline.com":{"status":"available","in_ga":"true","score":"0.441","spin":"yes"},"findmysiteshop.com":{"status":"available","in_ga":"true","score":"0.441","spin":"yes"},"ratemysite.biz":{"status":"available","in_ga":"true","score":"0.438","spin":"yes"},"sellmyplace.website":{"status":"available","in_ga":"true","score":"0.432","spin":"yes"},"sellmysitegroup.com":{"status":"available","in_ga":"true","score":"0.43","spin":"yes"},"sellmysiteonline.com":{"status":"available","in_ga":"true","score":"0.43","spin":"yes"},"sellmysiteshop.com":{"status":"available","in_ga":"true","score":"0.43","spin":"yes"},"findmysite.biz":{"status":"available","in_ga":"true","score":"0.429","spin":"yes"},"mysitegroup.website":{"status":"available","in_ga":"true","score":"0.42","spin":"yes"},"mysiteonline.website":{"status":"available","in_ga":"true","score":"0.42","spin":"yes"},"mysiteshop.website":{"status":"available","in_ga":"true","score":"0.42","spin":"yes"},"sellmysite.biz":{"status":"available","in_ga":"true","score":"0.42","spin":"yes"},"rate-my-website.com":{"status":"available","in_ga":"true","score":"0.415","spin":"yes"},"my-job-site.com":{"status":"available","in_ga":"true","score":"0.407","spin":"yes"},"my-site.us":{"status":"available","in_ga":"true","score":"0.398","spin":"yes"},"rate-my-site.website":{"status":"available","in_ga":"true","score":"0.398","spin":"yes"},"find-my-place.com":{"status":"available","in_ga":"true","score":"0.398","spin":"yes"},"ratemysite.us":{"status":"available","in_ga":"true","score":"0.397","spin":"yes"},"my-site.me":{"status":"available","in_ga":"true","score":"0.392","spin":"yes"},"ratemydomain.net":{"status":"available","in_ga":"true","score":"0.392","spin":"yes"},"find-my-site.website":{"status":"available","in_ga":"true","score":"0.391","spin":"yes"},"ratemysite.me":{"status":"available","in_ga":"true","score":"0.391","spin":"yes"},"sell-my-place.com":{"status":"available","in_ga":"true","score":"0.39","spin":"yes"},"findmysite.us":{"status":"available","in_ga":"true","score":"0.389","spin":"yes"},"ratemydomain.org":{"status":"available","in_ga":"true","score":"0.387","spin":"yes"},"sell-my-site.website":{"status":"available","in_ga":"true","score":"0.385","spin":"yes"},"findmysite.me":{"status":"available","in_ga":"true","score":"0.383","spin":"yes"},"my-site-group.com":{"status":"available","in_ga":"true","score":"0.381","spin":"yes"},"my-site-shop.com":{"status":"available","in_ga":"true","score":"0.381","spin":"yes"},"sellmysite.us":{"status":"available","in_ga":"true","score":"0.381","spin":"yes"}}
我尝试过以下代码
`$json_sug = file_get_contents($url_sug);
$json_data_sug = json_decode($json_sug, true);
var_dump($json_data_sug);`
答案 0 :(得分:0)
试试这个
$jason = '{"mysite.co":{"status":"available","in_ga":"true","score":"0.73","spin":"no"},"mysite.ooo":{"status":"available","in_ga":"true","score":"0.6","spin":"no"},"my-site.website":{"status":"available","in_ga":"true","score":"0.57","spin":"yes"},"ratemysite.website":{"status":"available","in_ga":"true","score":"0.568","spin":"yes"},"findmysite.website":{"status":"available","in_ga":"true","score":"0.557","spin":"yes"},"sellmysite.website":{"status":"available","in_ga":"true","score":"0.545","spin":"yes"},"rate-my-site.com":{"status":"available","in_ga":"true","score":"0.491","spin":"yes"},"my-domain.website":{"status":"available","in_ga":"true","score":"0.48","spin":"yes"},"ratemydomain.website":{"status":"available","in_ga":"true","score":"0.477","spin":"yes"},"findmydomain.website":{"status":"available","in_ga":"true","score":"0.466","spin":"yes"},"my-place.website":{"status":"available","in_ga":"true","score":"0.457","spin":"yes"},"sellmydomain.website":{"status":"available","in_ga":"true","score":"0.455","spin":"yes"},"myjobsite.website":{"status":"available","in_ga":"true","score":"0.455","spin":"yes"},"ratemyplace.website":{"status":"available","in_ga":"true","score":"0.455","spin":"yes"},"ratemysitegroup.com":{"status":"available","in_ga":"true","score":"0.451","spin":"yes"},"ratemysiteonline.com":{"status":"available","in_ga":"true","score":"0.451","spin":"yes"},"ratemysiteshop.com":{"status":"available","in_ga":"true","score":"0.451","spin":"yes"},"findmyplace.website":{"status":"available","in_ga":"true","score":"0.443","spin":"yes"},"sellmysite.org":{"status":"available","in_ga":"true","score":"0.442","spin":"yes"},"findmysitegroup.com":{"status":"available","in_ga":"true","score":"0.441","spin":"yes"},"findmysiteonline.com":{"status":"available","in_ga":"true","score":"0.441","spin":"yes"},"findmysiteshop.com":{"status":"available","in_ga":"true","score":"0.441","spin":"yes"},"ratemysite.biz":{"status":"available","in_ga":"true","score":"0.438","spin":"yes"},"sellmyplace.website":{"status":"available","in_ga":"true","score":"0.432","spin":"yes"},"sellmysitegroup.com":{"status":"available","in_ga":"true","score":"0.43","spin":"yes"},"sellmysiteonline.com":{"status":"available","in_ga":"true","score":"0.43","spin":"yes"},"sellmysiteshop.com":{"status":"available","in_ga":"true","score":"0.43","spin":"yes"},"findmysite.biz":{"status":"available","in_ga":"true","score":"0.429","spin":"yes"},"mysitegroup.website":{"status":"available","in_ga":"true","score":"0.42","spin":"yes"},"mysiteonline.website":{"status":"available","in_ga":"true","score":"0.42","spin":"yes"},"mysiteshop.website":{"status":"available","in_ga":"true","score":"0.42","spin":"yes"},"sellmysite.biz":{"status":"available","in_ga":"true","score":"0.42","spin":"yes"},"rate-my-website.com":{"status":"available","in_ga":"true","score":"0.415","spin":"yes"},"my-job-site.com":{"status":"available","in_ga":"true","score":"0.407","spin":"yes"},"my-site.us":{"status":"available","in_ga":"true","score":"0.398","spin":"yes"},"rate-my-site.website":{"status":"available","in_ga":"true","score":"0.398","spin":"yes"},"find-my-place.com":{"status":"available","in_ga":"true","score":"0.398","spin":"yes"},"ratemysite.us":{"status":"available","in_ga":"true","score":"0.397","spin":"yes"},"my-site.me":{"status":"available","in_ga":"true","score":"0.392","spin":"yes"},"ratemydomain.net":{"status":"available","in_ga":"true","score":"0.392","spin":"yes"},"find-my-site.website":{"status":"available","in_ga":"true","score":"0.391","spin":"yes"},"ratemysite.me":{"status":"available","in_ga":"true","score":"0.391","spin":"yes"},"sell-my-place.com":{"status":"available","in_ga":"true","score":"0.39","spin":"yes"},"findmysite.us":{"status":"available","in_ga":"true","score":"0.389","spin":"yes"},"ratemydomain.org":{"status":"available","in_ga":"true","score":"0.387","spin":"yes"},"sell-my-site.website":{"status":"available","in_ga":"true","score":"0.385","spin":"yes"},"findmysite.me":{"status":"available","in_ga":"true","score":"0.383","spin":"yes"},"my-site-group.com":{"status":"available","in_ga":"true","score":"0.381","spin":"yes"},"my-site-shop.com":{"status":"available","in_ga":"true","score":"0.381","spin":"yes"},"sellmysite.us":{"status":"available","in_ga":"true","score":"0.381","spin":"yes"}}';
$arr = json_decode($jason,TRUE);
$get_keys = array_keys($arr);
foreach($get_keys as $key){
echo $key;
}