我正在尝试在循环中创建这样的数组:
$dataPoints = array(
array('x' => 4321, 'y' => 2364),
array('x' => 3452, 'y' => 4566),
array('x' => 1245, 'y' => 3452),
array('x' => 700, 'y' => 900),
array('x' => 900, 'y' => 700));
用这个代码
$dataPoints = array();
$brands = array("COCACOLA","DellChannel","ebayfans","google",
"microsoft","nikeplus","amazon");
foreach ($brands as $value) {
$resp = GetTwitter($value);
$dataPoints = array(
"x"=>$resp['friends_count'],
"y"=>$resp['statuses_count']);
}
但是当循环完成时我的数组看起来像这样:
Array ( [x] => 24 [y] => 819 )