I dont know whats wrong but why I have undefined index since I already dump my array and it has values what could be wrong or I am missing?
//Here’s the screenshot:

//Here’s my php code:
$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;
}
This line:
nests one array within another.
Or just assign instead of appending in the earlier lines.