I have a switch function I want to be able to randomly pull cases from:
<?php
function peopleGet($name) {
switch ($name) {
case 'gloria':
echo 'gloria';
break;
case 'benjamin':
echo 'benjamin';
break;
case 'callum':
echo 'callum';
break;
}
}
?>
I still need to be able to pull specific variables:
<?php peopleGet('gloria'); ?>
However, is it possible to use the same function to be able to pull random (no-repeating) cases?
The answer is no (And really you shouldn’t) because the switch case statement is a control structure not a data structure, you would be better of having an array of values instead, plus instead of retuning a single value you can return multiple values
Something like: