Advertisement
enevlogiev

asd

Apr 29th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. $arr = array();
  2. $arr = array_fill(0, $size, array());
  3.  
  4. for ($i = 0; $i < count($arr); $i++) {
  5.     $arr[$i] = array_fill(0, $size, '|');
  6. }
  7.  
  8.  
  9. $str = 'Rvioes roi tset ';
  10. $index = 0;
  11. $row = 0;
  12. $col = 0;
  13.  
  14. while ($index < $size * $size) {
  15.     while ($arr[$row][$col] == '|' && $col < $size) {
  16.         $arr[$row][$col++] = $str[$index++ % strlen($str)];
  17.     }
  18.     $row += 1;
  19.     $col -= 1;
  20.     while ($arr[$row][$col] == '|' && $row < $size) {
  21.         $arr[$row++][$col] = $str[$index++ % strlen($str)];
  22.     }
  23.     $row -= 1;
  24.     $col -= 1;
  25.     while ($arr[$row][$col] == '|' && $col >= 0) {
  26.         $arr[$row][$col--] = $str[$index++ % strlen($str)];
  27.     }
  28.     $row -= 1;
  29.     $col += 1;
  30.     while ($arr[$row][$col] == '|' && $col >= 0) {
  31.         $arr[$row--][$col] = $str[$index++ % strlen($str)];
  32.     }
  33.     $row += 1;
  34.     $col += 1;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement