<?php function make_post_type($s) { preg_match_all("~({[^{}]*}|\[[^][]*])|[\w\s]+~", $s, $m); $s = ''; foreach($m[0] as $k => $v) { $s .= (bool) $m[1][$k] ? substr($v, 1, -1) : strtolower($v); } return preg_replace('~[-\s]+~', '_', $s); } echo make_post_type("[ABC] This & Text");
You have javascript disabled. You will not be able to edit any code.