fork download
  1. <?php
  2. // for e
  3. function pattern($n){
  4.  
  5. for($i=1;$i<=$n+2;$i++){
  6. echo str_repeat(" ",2*$n+1);
  7. echo str_repeat("e",2*i+1)."\n";
  8. }
  9. // for *
  10. for ($j=1;$j<=$i;$j++){
  11. echo str_repeat(" ",2*$n+1);
  12. echo str_repeat("*",$n-1);
  13. if($j==2 || $j==3){
  14. echo str_repeat("e").str_repeat("*",2*$n+1);
  15. }
  16. }
  17.  
  18. }
  19. pattern(3);
  20.  
Success #stdin #stdout #stderr 0.02s 25864KB
stdin
Standard input is empty
stdout
       e
       e
       e
       e
       e
       **       *********       *********       **       **       **
stderr
PHP Warning:  Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /home/jbenAv/prog.php on line 7
PHP Warning:  A non-numeric value encountered in /home/jbenAv/prog.php on line 7
PHP Warning:  Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /home/jbenAv/prog.php on line 7
PHP Warning:  A non-numeric value encountered in /home/jbenAv/prog.php on line 7
PHP Warning:  Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /home/jbenAv/prog.php on line 7
PHP Warning:  A non-numeric value encountered in /home/jbenAv/prog.php on line 7
PHP Warning:  Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /home/jbenAv/prog.php on line 7
PHP Warning:  A non-numeric value encountered in /home/jbenAv/prog.php on line 7
PHP Warning:  Use of undefined constant i - assumed 'i' (this will throw an Error in a future version of PHP) in /home/jbenAv/prog.php on line 7
PHP Warning:  A non-numeric value encountered in /home/jbenAv/prog.php on line 7
PHP Warning:  str_repeat() expects exactly 2 parameters, 1 given in /home/jbenAv/prog.php on line 14
PHP Warning:  str_repeat() expects exactly 2 parameters, 1 given in /home/jbenAv/prog.php on line 14