Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Crea dos arrays que se rellenen con los numeros del ARRAY principal, alternando los puestos
- srand ((double)microtime()*1000000);
- for($i=0; $i<10; $i++){
- $numeros[$i]=rand(1,100);
- }
- for($i=0; $i<count($numeros); $i++){
- echo $numeros[$i]." ";
- }
- echo "<br/>";
- $numeros1 = [];
- $numeros2 = [];
- for($i=0; $i<count($numeros); $i++){
- if($i%2 == 0){
- array_push($numeros1, $numeros[$i]);
- }
- else{
- array_push($numeros2, $numeros[$i]);
- }
- }
- for($i=0; $i<count($numeros1); $i++){
- echo $numeros1[$i]." ";
- }
- echo "<br>";
- for($i=0; $i<count($numeros2); $i++){
- echo $numeros2[$i]." ";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement