PHP代码:
print_r($InformationRetrieval['KeywordExtraction'][1]);
输出:
Array
(
[google] => 15
[search] => 18
[or] => 2
[web] => 4
[is] => 4
[a] => 5
[engine] => 2
}
但需要打印作为此数组索引的单词,例如:google,search或web等。
怎么做?
答案 0 :(得分:1)
您可以使用array_keys;
print_r(array_keys($InformationRetrieval['KeywordExtraction'][2]));
以下是一个有效的演示: Demo
答案 1 :(得分:0)
使用它:
<?php
$a = array("google" => 15, "search" => 18, "or" => 2, "web" => 4, "is" => 4, "a" => 5, "engine" => 2);
foreach($a as $key=>$value) {
echo $key;
}
?>