-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy patharrow.php
More file actions
43 lines (37 loc) · 795 Bytes
/
arrow.php
File metadata and controls
43 lines (37 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
$size = (int)$argv[1];
if(($size < 2) || ($size > 20)){
print 'Veuillez saisir un chiffre entre 2 et 20';
exit;
}
function base($size){
for ($i = 1; $i < ($size*2); $i++) {
print "* ";
}
}
function tail($size) {
print "\n";
for($i = 0; $i < $size; $i++) {
print str_repeat(' ', ($size*2)-2);
print "*\n";
}
}
function arrow($size) {
$nb = 0;
for($i = 0; $i < $size-1; $i++) {
$nb += 2;
$space = ($size*2)-$nb;
if($nb == 2){
print str_repeat(' ', $space);
print "*\n";
} else {
print str_repeat(' ', $space);
print "*";
print str_repeat(' ', $nb*2-6);
print " *\n";
}
}
}
arrow($size);
base($size);
tail($size);