This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function shuffleClass($input_array, $num_of_stud){ | |
if (is_array($input_array) && count($input_array)>2 && is_integer($num_of_stud) && abs($num_of_stud) <= count($input_array)): | |
// number is negative | |
if ($num_of_stud < 0): | |
for($i=0; $i<abs($num_of_stud); $i++){ | |
$array1[] = $input_array[$i]; | |
} | |
$array2 = array_diff($input_array, $array1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// initial array entry | |
$initial_array = [4, 8, 2, 5, 2]; | |
// initialise variable to store the final array | |
$final_array = array(); | |
// get the number of elements in the initial array | |
$numberOfElements = count($initial_array); | |
if (!empty($initial_array) && is_array($initial_array) && $numberOfElements > 0){ | |
for($i=0; $i<$numberOfElements; $i++){ |