I’m making a simple yahtzee script in PHP, I’ve got up the final point where it checks the 5 dice for a result at the end.
The 5 dice sides are stored in an array, example $dice (2,5,2,7,8)
I’m not that experienced in working with arrays, but is there easier ways to compare each number, to like find instances of 2 the same, 3 the same, all the same etc?
array_search() ?
array_count_values()might be a function that’s worth looking at. It will count the number of instances of a value in an array.Example: