3v4l.org

run code in 300+ PHP versions simultaneously
<?php function slug( $string, $separator = '-' ) { $accents_regex = '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i'; $special_cases = array( '&' => 'and', "'" => ''); $string = mb_strtolower( trim( $string ), 'UTF-8' ); $string = str_replace( array_keys($special_cases), array_values( $special_cases), $string ); $string = preg_replace( $accents_regex, '$1', htmlentities( $string, ENT_QUOTES, 'UTF-8' ) ); $string = preg_replace("/\s+/", "$separator", $string); $string = preg_replace("/[$separator]+/u", "$separator", $string); return $string; } echo slug("um rĂ¡dio bonito");
Output for git.master, git.master_jit, rfc.property-hooks
um-radio-bonito

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:
28.96 ms | 405 KiB | 5 Q