fork download
  1. <?php
  2. $string = "aaaaa, bbb ,cccc, hhhh, fff,t";
  3.  
  4. $regex = '~(\w+)(\s*,|$)~';
  5.  
  6. $regex,
  7. function($match) {
  8. return str_pad($match[1], 10);
  9. },
  10. $string);
  11. echo $string;
  12. ?>
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
aaaaa      bbb       cccc       hhhh       fff       t