I am using PHP and a multidimensional array. I have stored points and other information as string variables. It is very important that I use string variables in my array.
I would like to sort the array and add 3 new items. I should be able to sort my subarrays. I also should be able to sort my string variables of points (pts_sting) and competitions (c_string).
I need some kind of foreach loop to do the job automatically.
Maybe the following example helps more than my words.
Array (
[25] => Array (
[1] => Array (
[pts_string] => 00450
[c_string] => 00011
)
[2] => Array (
[pts_string] => 00600
[c_string] => 00025
)
[3] => Array (
[pts_string] => 00375
[c_string] => 00033
)
)
)
The result should look like this:
Array (
[25] => Array (
[pts_total] = 1425 /* 600 + 450 + 375 */
[all_pts_strings] = 00600 00450 00375 /* biggest points, 2nd biggest, etc. */
[all_c_strings] = 00025 00011 00033 /* competition of biggest points, 2nd biggest, etc. */
[no_of_competitions] = 3 /* [1], [2], and [3] = 3 in total */
/* biggest points first... */
[2] => Array (
[pts_string] => 00600
[c_string] => 00025
)
/* 2nd biggest points... */
[1] => Array (
[pts_string] => 00450
[c_string] => 00011
)
/* 3rd biggest points... */
[3] => Array (
[pts_string] => 00375
[c_string] => 00033
)
)
)