public static function textCleaner($input, $joker = '_', $maxLength = -1)
    {
        $returnValue = '';

        $randJoker = ($joker == '*');
        $length =  ((defined('TAO_DEFAULT_ENCODING')) ? mb_strlen($input, TAO_DEFAULT_ENCODING) : mb_strlen($input));
        if($maxLength > -1 ){
            $length = min($length, $maxLength);
        }

		$i = 0;
		while ($i < $length){
			if (preg_match("/^[a-zA-Z0-9_-]{1}$/u", $input[$i])){
				$returnValue .= $input[$i];
			}
			else{
				if ($input[$i] == ' '){
					$returnValue .= '_';
				}
				else{
					$returnValue .= ((true === $randJoker) ? chr(rand(97, 122)) : $joker);
				}
			}
			$i++;
		}

        return (string) $returnValue;
    }
public static function textCleaner($input, $joker = '_', $maxLength = -1)
    {
        $returnValue = '';

        $randJoker = ($joker == '*');
        $length =  ((defined('TAO_DEFAULT_ENCODING')) ? mb_strlen($input, TAO_DEFAULT_ENCODING) : mb_strlen($input));
        if($maxLength > -1 ){
            $length = min($length, $maxLength);
        }

		$i = 0;
		while ($i < $length){
			if (preg_match("/^[a-zA-Z0-9_-]{1}$/u", $input[$i])){
				$returnValue .= $input[$i];
			}
			else{
				if ($input[$i] == ' '){
					$returnValue .= '_';
				}
				else{
					$returnValue .= ((true === $randJoker) ? chr(rand(97, 122)) : $joker);
				}
			}
			$i++;
		}

        return (string) $returnValue;
    }
public static function textCleaner ( $ input , $ joker = '_' , $ maxLength = - 1 ) { $ returnValue = '' ; $ randJoker = ( $ joker == '*' ) ; $ length = ( ( defined ( 'TAO_DEFAULT_ENCODING' ) ) ? mb_strlen ( $ input , TAO_DEFAULT_ENCODING ) : mb_strlen ( $ input ) ) ; if ( $ maxLength > - 1 ) { $ length = min ( $ length , $ maxLength ) ; } $ i = 0 ; while ( $ i < $ length ) { if ( preg_match ( "/^[a-zA-Z0-9_-]{1}$/u" , $ input [ $ i ] ) ) { $ returnValue .= $ input [ $ i ] ; } else { if ( $ input [ $ i ] == ' ' ) { $ returnValue .= '_' ; } else { $ returnValue .= ( ( true === $ randJoker ) ? chr ( rand ( 97 , 122 ) ) : $ joker ) ; } } $ i ++ ; } return ( string ) $ returnValue ; }
Clean a text with a joker character to replace any characters that is
alphanumeric.

@author Bertrand Chevrier, <bertrand.chevrier@tudor.lu>
@param  string input The string input.
@param  string joker (optional, default = '_') A joker character that will be the alphanumeric placeholder.
@param  int maxLength (optional, default = -1) output maximum length
@return string The result string.
Clean a text with a joker character to replace any characters that is alphanumeric .