Hi all, Can I use array_push to push a full array into another array to make a multidimensional array. Here is my code

$detailsarray = array(Teamname => $userid, Player1 => $userid, Player2 => $Player2);
array_push($playerarray,$detailsarray);

I need this to keep track of players in an event. When the new array is created I update the database and that can then be pulled on another page to see who is in the event. When a new person signs up then they are just added to the end of the array with there team details. Am I going about this the right way?

    I thought that I and sneakyimp told you that this is the wrong way to handle everything in this thread.

      With the other thread and the normalization issue the players in the event are only specific to each specific event. The details of the players can change and need to be stored per event. I know that I just store the players in an array and put that in the database that works absolutely fine. But to store there details as well the array needs to be multidimensional. I can not see any other way around it. I mean I could have a seperate field for each player in the event table but what if I have 255 players thats a big table. Is there any way to store the players and there details in one field?

        Yes, in another table that have a relationship to the event table. If you had bothered to read up on database normalization you would know this since it is explained in every tutorial I have seen, it is first normal form.

          Write a Reply...