使用Angular.js访问php数组数据

I've already asked a question like this but i'm getting issues. I'm using angular.js to send data to a php file. This php file is gathering a list of data and storing this in an array. I'm then encoding this array and sending it back to angular on a success function. I need to display each array one after the other on each other.

Any suggestions ?

if($result){
 while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){


  $Participants = array(
            firstname => $row['firstname'],
            lastname => $row['lastname'],
            amount => $row['longitude']
        );


 }

}

echo json_encode($Participants);

My angular

     angular.forEach(response.data, function(value, key){

        var Participants = {};

        Participants = {

          firstname: value['firstname'],
          lastname: value['lastname'],
          amount: value['amount'], 
        };

        console.log(Participants);

        });

Your array will only ever hold one participant. Declare it above the loop, and append to it within:

$Participants = array();

if($result) {
    while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){

        $Participants[] = array(
            firstname => $row['firstname'],
            lastname => $row['lastname'],
            amount => $row['longitude']
        );
}

A similar issue exists in your client-side angular code:

// Note this is now an array instead of plain object
var Participants = []; 
angular.forEach(response.data, function(value, key){
    Participants.push({
        firstname: value['firstname'],
        lastname: value['lastname'],
        amount: value['amount'], 
    });
});


console.log(Participants);