fork(1) download
  1. <?php
  2.  
  3. $str = "aaaaaaaaaa";
  4. $carater="-";
  5. $apartir=3;
  6. $ate=7;
  7. $ambos="ambos";
  8. $entre="entre";
  9. $compr=strlen($str);
  10.  
  11. if ($apartir==3){
  12. $nome=substr($str, $compr-$apartir, $compr);
  13. $right = str_pad($nome, $compr, $carater, STR_PAD_RIGHT);
  14. }
  15.  
  16. if ($ate==7){
  17. $nome=substr($str, $compr-$apartir, $compr);
  18. $left = str_pad($nome, $compr, $carater, STR_PAD_LEFT);
  19. }
  20.  
  21. if($ambos=="ambos"){
  22. $nome=substr($str, $ate, $compr);
  23. $both = str_pad($nome, $compr, $carater, STR_PAD_BOTH);
  24. }
  25.  
  26. echo $right;
  27. echo "\n";
  28. echo $left;
  29. echo "\n";
  30. echo $both;
  31. echo "\n";
  32.  
  33. $quant=2;
  34.  
  35. $parts = str_split($str, $quant);
  36. $inicio = $fim = $parts[0];
  37.  
  38. $aux=substr($str,$quant*2,$compr);
  39.  
  40. $compl=str_replace("a",$carater,$aux);
  41.  
  42. $meio=$inicio.$compl.$fim;
  43. echo $meio;
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
aaa-------
-------aaa
---aaa----
aa------aa