简体   繁体   中英

Add additional data into a multidimensional array - PHP

The following piece of code

$rank = array
        (
        array($row['Name'],$passed,$target,$target2,$TotalScore)
        );

is temp. holding information of the total scores of a competition.

However, the complexity of my outer loop works through and totals up all the scores before it pops it into this array.

John West - Yes - 250 - 750 - 1000

Then the loop will continue this process and will then end up with a list of names and their scores - sorted of course. So basically creating a list which I can then sort and create a ranking table.

I'm not sure how the above code could be manipulated so I can insert at the next part of the array after the totalling has been done.

I remember years ago I could do something in other languages like:- $rank[1][0] = Dave Burt, No, 100, 300, 400;

Any suggestions? I got a feeling this is going to be straight forward.

Simple, do in this way

You can define new_array as

$new_array=(" "," ",...)

And append it like this

$rank->append(new_array)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM