rjangelov

ArraysInPHP - //Problem 1. Print array

Jun 25th, 2014
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1. //Problem 1.    Print array
  2. //Write a script that allocates array of 20 integers and initializes each element by its index multiplied by 5. Print the obtained array //on the console.
  3. <!DOCTYPE html>
  4. <html>
  5.     <head>
  6.         <meta charset="UTF-8">
  7.         <title></title>
  8.     </head>
  9.     <body>
  10.         <?php
  11.         foreach(range(0, 20, 1) as $v=>$k){
  12.             $myArray[$k]=$k*5;
  13.         }
  14.         echo '<pre>' . print_r($myArray, true) . '</pre>';
  15.         ?>
  16.     </body>
  17. </html>
Advertisement
Add Comment
Please, Sign In to add comment