3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $strings = array( 'this is a string', 'this is $ a string', 'this is 12 string', 'this is $12.99 string', ); foreach ($strings as $string) { var_dump(strtolower(preg_replace('#[\s?]#', '-', preg_replace('#[^a-z0-9\-\s]#', '', $string)))); }
Output for 4.3.0 - 7.2.0
string(16) "this-is-a-string" string(17) "this-is--a-string" string(17) "this-is-12-string" string(19) "this-is-1299-string"