3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "[ABC] This & Text"; Echo make_post_type($string); function make_post_type($string) { $needle = array('-', ' '); $arr = explode(" ", $string); foreach($arr as &$a){ if($a[0] != "[" && $a[-1] != "]"){ $a = preg_replace("/[^a-zA-Z0-9_\s]/", "", strtolower($a)); // Remove special characters }else{ $a = substr($a, 1,-1); } } $string = preg_replace('!\s+!', ' ', implode(" ", $arr)); // Now remove extra spaces return str_replace($needle, '_', $string); }
Output for git.master, git.master_jit, rfc.property-hooks
ABC_this_text

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