我不知道出了什么问题,但为什么我有未定义的索引,因为我已经转储了我的数组并且它的值可能是错误的或我丢失了?
//这里是截图:
//这是我的php代码:
$result1 = array(); //for player 1
$result2 = array(); //for player 2
$data_blue = $db->dataWarrior($battle,$blue_name,$blue_type);
foreach($data_blue as $blue){
$result1[] = $blue;
}
$data_red = $db->dataWarrior($battle,$red_name,$red_type);
foreach($data_red as $red){
$result2[] = $red;
}
var_dump($result1);
//variables to identify turns 1=turn
$warrior_1 = 0;
$warrior_2 = 0;
//compare speed
if($result1['speed']>$result2['speed']){ //this is the undefined index
$warrior_1 = 1;
$warrior_2 = 0;
}