Tricky array problem
Posted: Fri Nov 21, 2003 10:14 am
i have two arrays containing the following values
Array1
Array2
The first array is the day number of the year that someone is having as holiday from work, the second array corresponds to that persons name.
On my calendar script, on each day, i check to see if the current day is present in Array1. If it is, i output the employees name into that days cell.
The problem come when two people have the same day off.
array_search only returns the last one it finds (or the first one, not sure).
My ideal solution would be to create new arrays. The first would contain the unique days that people are having off. If on one of those days, there are two people off, the corresponding value in athe other array would be something like "Mark, Claire".
How can i create these two new arrays from the ones i currently have. Arrays really aren't my strong point, so any help would be greatly appreciated.
Thanks
Mark
Array1
Code: Select all
Array
(
[0] => 250
[1] => 251
[2] => 252
[3] => 253
[4] => 254
[5] => 257
[6] => 258
[7] => 264
[8] => 265
[9] => 266
[10] => 278
[11] => 279
[12] => 280
[13] => 281
[14] => 282
[15] => 271
[16] => 272
[17] => 273
[18] => 274
[19] => 148
[20] => 149
[21] => 152
[22] => 153
[23] => 154
[24] => 34
[25] => 35
[26] => 36
[27] => 37
[28] => 40
[29] => 41
[30] => 42
[31] => 43
[32] => 44
[33] => 47
[34] => 48
[35] => 49
[36] => 218
[37] => 219
[38] => 222
[39] => 127
[40] => 128
[41] => 131
[42] => 132
[43] => 131
)Code: Select all
Array
(
[0] => Mark
[1] => Mark
[2] => Mark
[3] => Mark
[4] => Mark
[5] => Mark
[6] => Mark
[7] => Katie
[8] => Katie
[9] => Katie
[10] => Sean
[11] => Sean
[12] => Sean
[13] => Sean
[14] => Sean
[15] => Claire
[16] => Claire
[17] => Claire
[18] => Claire
[19] => Alison
[20] => Alison
[21] => Alison
[22] => Alison
[23] => Alison
[24] => Mark
[25] => Mark
[26] => Mark
[27] => Mark
[28] => Mark
[29] => Mark
[30] => Mark
[31] => Mark
[32] => Mark
[33] => Mark
[34] => Mark
[35] => Mark
[36] => Katie
[37] => Katie
[38] => Katie
[39] => Rebecca
[40] => Rebecca
[41] => Rebecca
[42] => Rebecca
[43] => Mark
)On my calendar script, on each day, i check to see if the current day is present in Array1. If it is, i output the employees name into that days cell.
The problem come when two people have the same day off.
array_search only returns the last one it finds (or the first one, not sure).
My ideal solution would be to create new arrays. The first would contain the unique days that people are having off. If on one of those days, there are two people off, the corresponding value in athe other array would be something like "Mark, Claire".
How can i create these two new arrays from the ones i currently have. Arrays really aren't my strong point, so any help would be greatly appreciated.
Thanks
Mark