3v4l.org

run code in 300+ PHP versions simultaneously
<?php function remapInternationalCharToAscii($c) { return $c; } function sluggify($title) { if ($title === null) return ""; $maxlen = 80; $len = strlen($title); $prevdash = false; $slug = ""; for ($i = 0; $i < $len; $i++) { $c = $title[$i]; if (($c >= 'a' && $c <= 'z') || ($c >= '0' && $c <= '9')) { $slug .= $c; $prevdash = false; } else if ($c >= 'A' && $c <= 'Z') { echo 'hi!'; $slug .= strtolower($c); $prevdash = false; } else if ($c == ' ' || $c == ',' || $c == '.' || $c == '/' || $c == '\\' || $c == '-' || $c == '_' || $c == '=') { if (!$prevdash && strlen($slug) > 0) { $slug .= '-'; $prevdash = true; } } else if ((int) $c >= 128) { $prevlen = strlen($slug); $slug .= remapInternationalCharToAscii($c); if ($prevlen != strlen($slug)) $prevdash = false; } if ($i == $maxlen) break; } if ($prevdash) { return substr($slug, 0, strlen($slug) - 1); } return $slug; } echo sluggify('Hello World');
Output for git.master, git.master_jit, rfc.property-hooks
hi!hi!hello-world

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:
51.16 ms | 401 KiB | 8 Q