Skip to content

Instantly share code, notes, and snippets.

@yunchih
Created August 23, 2014 05:18
Show Gist options
  • Save yunchih/596b5d47cfb403153234 to your computer and use it in GitHub Desktop.
Save yunchih/596b5d47cfb403153234 to your computer and use it in GitHub Desktop.
<?php
$A = array();
$B = array();
$C = array();
echo 'Array A :<br/>';
for($i=0;$i<10;$i++){
$random = rand(1,30);
array_push($A, $random);
echo $random . " ";
}
echo '<br>';
/*------------------*/
for($i=0;$i<10;$i++){
$current_number = $A[$i];
if($current_number>15){
array_push($B,$current_number);
}
else{
array_push($C,$current_number);
}
}
echo 'Array B:<br/>';
for ($i=0; $i < count($B); $i++) {
echo $B[$i] . " ";
}
echo '<br/>';
/*----------------------------*/
echo 'Array C:<br/>';
for ($i=0; $i < count($C); $i++) {
echo $C[$i] . " ";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment