所以我正在 print_r-ing 一个数组,生成如下:
while ($twitgroup = mysql_fetch_array($resulttwitter)) {
print_r($twitgroup);
}
我得到这个输出(有多个数组,取决于行)。
Array ( [0] => composed [category] => composed [1] => 330 [value] => 330 [2] => 1344384476.94 [timestamp] => 1344384476.94 ) Array ( [0] => elated [category] => elated [1] => 2034 [value] => 2034 [2] => 1344384476.94 [timestamp] => 1344384476.94 ) Array ( [0] => unsure [category] => unsure [1] => 2868 [value] => 2868 [2] => 1344384476.94 [timestamp] => 1344384476.94 ) Array ( [0] => clearheaded [category] => clearheaded [1] => 1008 [value] => 1008 [2] => 1344384476.94 [timestamp] => 1344384476.94 ) Array ( [0] => tired [category] => tired [1] => 2022 [value] => 2022 [2] => 1344384476.94 [timestamp] => 1344384476.94 )
我希望能够在这里提取个人价值观,但我遇到了麻烦。我正在尝试在这些数组上使用 while 循环,但我认为这可能是错误的。我是否应该使用 foreach 循环,然后在该 foreach 的输出上访问数组的每个元素?
比方说,我要抓取composition,以及committed 的值。我该怎么做?
我非常擅长 Python 中的数组/列表,但我在 PHP 中的数组经验有些欠缺。