davaze wrote:Thanks for your comments however i think a boolean value can be specified several ways like: 'true' or 'false', 'yes' or 'no' and also 0 or 1. All have the same boolean function in my opinion. Just sending over 0 or 1 is more easy then sending over string values but that's just a personal preference and can be easily changed if you want.
Certainly. However, PHP has a boolean type with literals true and false, thus it makes sense to use it when you really do want a boolean type. Furthermore, instead of doing a typical boolean check, your code checks for the integer value, e.g.,
if ($reverse == 1){
instead of:
if ($reverse){
This can be an advantage if you intend the flag to be a numeric flag instead, e.g., for different shuffling options, but then 0 and 1 become magic numbers, which is a Bad Thing.
davaze wrote:Using the shuffle flag and or reverse flag are just options to have it all go in one call instead of having to do them seperate, also this is a personal preference and for some this way might be as easy as the other way.
What I am saying is that your shuffle option clutters the interface. Instead of writing:
$schedule = scheduler($members, 1);
you can write:
shuffle($members);
$schedule = scheduler($members);
If there was a version of shuffle that returned the array shuffled instead, then even better, e.g.,
$schedule = scheduler(shuffle_return($members));
davaze wrote:In this case it works with the arrays itself nomather what's inside.
Indeed, which is why I think that the shuffle option clutters the interface. You have provided a good way to get input, so take advantage of it.
davaze wrote:Anyway use it to your own adventage and or change it the way you like. I just posted it as a starting point for people to use if they needed something like this, like me :-)
This is the Code Critique forum, so you should expect a code critique 😉
If I wanted to do something like your version, I would just modify my version to allow for similiar input and output 🙂