Confusing? yes. and I am not sure how to work it out.
I have following scenario:
- 3 vendors in array (=>A,=>B,=>C)
Now I need to assign this to another array which is 5 long for each day of the week (excluding Sunday and Saturday).
So, lets say today is Wednesday then the output should be:
[Wed] => A
[Thu] => B
[Fri] => C
[Mon] => A
[Tue] => B
I can't figure out how to achieve this. I have no code to display as its just concept and am only thinking how to do it. Tried to write code and even tried to draw it out on paper but can't figure out an easier way to do it without having lots of if and for statements.
If the first array is always the same, you can use the index of the array to determine the DAY.
You can say M = 0 and F = 4.
Then use the modulus operator to cycle the 5 into 3
Example for Tues:
1 % 3 = 1, so the value of Tuesday is $array, which is B.
Example for Thursday:
3 % 3 = 0, so the value of Thursday is $array, which is A.
Is it true to say that from today (Friday) I want to use each supplier in turn (A, B, C) ad infinitum?
Or could that change at some point, and that on another day I will switch and suddenly have only two, or have four, or five?
First array is not same. It can change
and yes, that array can change as we add/edit vendors. That's why the problem. Have to go to 5 days in the array and select 5 vendors (first one repeating if less than 5).
How many weeks worth of matches do you have to generate?
How will you store the fact that the last used supplier was say, B, in order to generate the new set of matches when the first array of suppliers has to be regenerated? Is this in a text file, database?
Thanks for all the replies.
It was to be for 5 days only. Now I say was, because the idea has been changed on how to take that approach so this is not needed anymore.
This topic is now closed. New replies are no longer allowed.