fork download
  1. <?php
  2.  
  3. $text = 'Të$ting slugificatiön';
  4.  
  5. // construct the pipeline
  6. $valuePlaceholder = new stdClass;
  7. $pipeline = array(
  8. array('preg_replace', array('~[^\\pL\d]+~u', '-', $valuePlaceholder)),
  9. array('trim', array($valuePlaceholder, '-')),
  10. array('iconv', array('utf-8', 'us-ascii//TRANSLIT', $valuePlaceholder)),
  11. // etc etc
  12. );
  13.  
  14. // process it
  15. $value = $text;
  16. foreach ($pipeline as $stage) {
  17. list($callable, $parameters) = $stage;
  18. foreach ($parameters as &$parameter) {
  19. if ($parameter === $valuePlaceholder) {
  20. $parameter = $value;
  21. }
  22. }
  23. $value = call_user_func_array($callable, $parameters);
  24. }
  25.  
  26. // final result
  27. echo $value;
  28.  
  29. ?>
Success #stdin #stdout 0.02s 13136KB
stdin
Standard input is empty
stdout
Te-ting-slugification