Is there any good or standard way of doing this?
Take the following example:
$values = array(
'blue'
, 'blue'
, 'blue'
, 'blue'
, 'green'
, 'red'
, 'yellow'
, 'yellow'
, 'purple'
, 'purple'
, 'purple'
);
I need it to be separated so no two identical values are touching (unless there is no possible solution -- in which case either generating an error, returning false or anything else is acceptable).
Here's the above array (done by hand) but how I am trying to change it:
$values = array(
'blue'
, 'purple'
, 'green'
, 'purple'
, 'blue'
, 'red'
, 'blue'
, 'yellow'
, 'blue'
, 'yellow'
, 'purple'
)
The values won't necessarily be in order in the beginning -- that was just for simplicities sake.
Any ideas? Any code to get me started in the right direction?