public static function camelCaseToSeparator($text, $sep = " ")
    {
        if (!is_scalar($text) && !is_array($text)) {
            return $text;
        }
        if (self::hasPcreUnicodeSupport()) {
            $pattern = array(
                '#(?<=(?:\p{Lu}))(\p{Lu}\p{Ll})#',
                '#(?<=(?:\p{Ll}|\p{Nd}))(\p{Lu})#'
            );
            $replacement = array($sep.'\1', $sep.'\1');
        } else {
            $pattern = array(
                '#(?<=(?:[A-Z]))([A-Z]+)([A-Z][a-z])#',
                '#(?<=(?:[a-z0-9]))([A-Z])#');
            $replacement = array('\1'.$sep.'\2', $sep.'\1');
        }
        return preg_replace($pattern, $replacement, $text);
    }
public static function camelCaseToSeparator($text, $sep = " ")
    {
        if (!is_scalar($text) && !is_array($text)) {
            return $text;
        }
        if (self::hasPcreUnicodeSupport()) {
            $pattern = array(
                '#(?<=(?:\p{Lu}))(\p{Lu}\p{Ll})#',
                '#(?<=(?:\p{Ll}|\p{Nd}))(\p{Lu})#'
            );
            $replacement = array($sep.'\1', $sep.'\1');
        } else {
            $pattern = array(
                '#(?<=(?:[A-Z]))([A-Z]+)([A-Z][a-z])#',
                '#(?<=(?:[a-z0-9]))([A-Z])#');
            $replacement = array('\1'.$sep.'\2', $sep.'\1');
        }
        return preg_replace($pattern, $replacement, $text);
    }
public static function camelCaseToSeparator ( $ text , $ sep = " " ) { if ( ! is_scalar ( $ text ) && ! is_array ( $ text ) ) { return $ text ; } if ( self :: hasPcreUnicodeSupport ( ) ) { $ pattern = array ( '#(?<=(?:\p{Lu}))(\p{Lu}\p{Ll})#' , '#(?<=(?:\p{Ll}|\p{Nd}))(\p{Lu})#' ) ; $ replacement = array ( $ sep . '\1' , $ sep . '\1' ) ; } else { $ pattern = array ( '#(?<=(?:[A-Z]))([A-Z]+)([A-Z][a-z])#' , '#(?<=(?:[a-z0-9]))([A-Z])#' ) ; $ replacement = array ( '\1' . $ sep . '\2' , $ sep . '\1' ) ; } return preg_replace ( $ pattern , $ replacement , $ text ) ; }
Converts camel case strings to words separated by provided string

@param string $text The text to evaluate
@param string $sep  The separator (or glue) for the words

@return string
Converts camel case strings to words separated by provided string