How can I select two unique random from and array and check that it are not equal with one pre-selected (default value)? For example I have an array of months like
$months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
and a given month $alreadyin = "Feb"; now I need to select two unique months which are not equal to $alreadyin?
<?php
$alreadyin = "Feb";
$months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
$rand_months = array_rand($months, 2);
?>
$rand_monthswith$alreadyin. If it's in, do array rand again. You can put it in a while loop that only exits when two uniques are generated.