3v4l.org

run code in 300+ PHP versions simultaneously
<?php function slugify($title) { $output = ''; $valid_characters = 'abcdefghijklmnopqrstuvwxyz1234567890'; $len = strlen($title); for ($i = 0;$i < $len;$i++) { if (stripos($valid_characters, $title[$i]) !== FALSE) { // Letters and numbers are valid $output .= strtolower($title[$i]); } elseif ($i > 0 && $title[$i] !== '\'' && stripos($valid_characters, $title[$i - 1]) !== FALSE) { // Other characters are turned into dashes, but never two // in a row. $output .= '-'; } } if (substr($output, -1, 1) === '-') { return substr($output, 0, -1); } else { return $output; } } echo slugify('This is not a love song').PHP_EOL; echo slugify('There\'s a lady who is sure').PHP_EOL; echo slugify('All that is gold does not glitter ').PHP_EOL;
Output for git.master, git.master_jit, rfc.property-hooks
this-is-not-a-love-song theres-a-lady-who-is-sure all-that-is-gold-does-not-glitter

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
35.97 ms | 401 KiB | 8 Q