This is my code:
if ( 0 < $matches->total() ) {
while ( $matches->fetch() ) {
?>
<?php $ma1_winner = $matches->display( 'winner' ); ?>
<?php $ma1_team_1 = $matches->display( 'team_1' ); ?>
<?php $matches_array_1['winner'] = $ma1_winner; ?>
<?php $matches_array_1['team1'] = $ma1_team_1; ?>
<?php
} // end of while loop
} // end of if any exists
?>
<?php var_dump($matches_array_1); ?>
<?php die(); ?>
But it outputs in var_dump only one winner and team not 15 from my database. How to fix it?
For each iteration, append a new array with
winnerandteamas its keys. The result will be a 2-dimensional array containing all your values.Otherwise, you are just overwriting the same two keys
winnerandteamon every iteration.