This is the code I'm using:
<?php
function getKeywordSuggestionsFromGoogle($keyword) {
$keywords = array();
$data = file_get_contents('http://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl=en-US&q='.urlencode($keyword));
if (($data = json_decode($data, true)) !== null) {
$keywords = $data[1];
}
return $keywords;
}
var_dump(getKeywordSuggestionsFromGoogle('money'));
And it displays this on my page:
["money",["moneygram","money network","money mutual","moneypak","money saving mom","moneyball","money","money converter","money order","moneygram walmart"]]
What needs to make it display like this instead?
moneygram, money network, money mutual, moneypak, money saving mom, moneyball, money, money converter, money order, moneygram walmart
Do something like this: Use json_decode
and then simply implode
it
<?php
$json_code = '["money",["moneygram","money network","money mutual","moneypak","money saving mom","moneyball","money","money converter","money order","moneygram walmart"]]';
$data = json_decode($json_code);
echo implode(',',$data[1]);
?>
This gives you output as:
moneygram, money network, money mutual, moneypak, money saving mom, moneyball, money, money converter, money order, moneygram walmart
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.