CodeIgniter Forums
uncamelize - Inflector Helper Extension - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: uncamelize - Inflector Helper Extension (/showthread.php?tid=29961)



uncamelize - Inflector Helper Extension - El Forum - 04-27-2010

[eluser]darkhouse[/eluser]
I needed to take some camelized strings and convert them back to regular strings, so I made this little function to extend the inflector helper. I know it's not much, but I searched the forums for it and couldn't find anything, so here it is if anyone needs it.

Code:
if(!function_exists('uncamelize')){
    function uncamelize($str, $delimiter=' '){
        $str = strtolower(preg_replace('/([A-Z])/', $delimiter.'$1', $str));
        return $str;
    }
}