This function sanitizes certain abbreviations into readable format.

@param $string
@return string
434519
final private function convertToTitle($string)
    {
        $string2 = [];
        $string = str_replace(['_', 'AVE.', 'BLVD.'], [' ', 'AVENUE', 'BOULEVARD'], $string);
        $words = explode(' ', $string);

        foreach ($words as $word) {
            if (!in_array($word, ['EDSA', 'U.N.'])) {
                $word = ucwords(mb_strtolower($word));
            }
            array_push($string2, $word);
        }

        return implode(' ', $string2);
    }
1151612
protected function studlyCase($string)
    {
        return preg_replace_callback('/(?:^|(\w)-)(\w)/', function($match) {
            return $match[1] . strtoupper($match[2]);
        }, strtolower(addcslashes($string, '\\')));
    }
697297
public static function clean($string)
	{
		if (empty($string))
		{
			return $string;
		}

		if (get_magic_quotes_gpc())
		{
			$string = stripslashes($string);
		}

		// strip out any KL_PHP, script, style, HTML comments
		$string = preg_replace('/{kl_php}(.*?){\/kl_php}/is', '', $string);
		$regex =
			'/(<link[^>]+rel="[^"]*stylesheet"[^>]*>|' .
			'<script[^>]*>.*?<\/script>|' .
			'<style[^>]*>.*?<\/style>|' .
			'<\?php.*?\?>|' .
			'<!--.*?-->)/is';
		$string = preg_replace($regex, '', $string);

		$string = str_replace(
			array('&amp;',     '&lt;',     '&gt;'),
			array('&amp;amp;', '&amp;lt;', '&amp;gt;'),
			$string
		);
		// Fix &entitiy\n;

		$string = preg_replace('#(&\#*\w+)[\x00-\x20]+;#u', "$1;", $string);
		$string = preg_replace('#(&\#x*)([0-9A-F]+);*#iu', "$1$2;", $string);
		//$string = html_entity_decode($string, ENT_COMPAT, "UTF-8");

		// Remove any attribute starting with "on" or xmlns
		$string = preg_replace('#(<[^>]+[\x00-\x20\"\'])(on|xmlns)[^>]*>#iUu', "$1>", $string);

		// Remove javascript: and vbscript: protocol
		$string = preg_replace('#([a-z]*)[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*)[\\x00-\x20]*j[\x00-\x20]*a[\x00-\x20]*v[\x00-\x20]*a[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2nojavascript...', $string);
		$string = preg_replace('#([a-z]*)[\x00-\x20]*=([\'\"]*)[\x00-\x20]*v[\x00-\x20]*b[\x00-\x20]*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:#iUu', '$1=$2novbscript...', $string);

		// <span style="width: expression(alert('Ping!'));"></span>
		// only works in ie...
		$string = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*expression[\x00-\x20]*\([^>]*>#iU', "$1>", $string);
		$string = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*behaviour[\x00-\x20]*\([^>]*>#iU', "$1>", $string);
		$string = preg_replace('#(<[^>]+)style[\x00-\x20]*=[\x00-\x20]*([\`\'\"]*).*s[\x00-\x20]*c[\x00-\x20]*r[\x00-\x20]*i[\x00-\x20]*p[\x00-\x20]*t[\x00-\x20]*:*[^>]*>#iUu', "$1>", $string);

		// Remove namespaced elements (we do not need them...)
		$string = preg_replace('#</*\w+:\w[^>]*>#i', '', $string);

		// Remove really unwanted tags
		$string = self::stripTags($string,
			'applet', 'meta', 'xml', 'blink', 'link', 'style',
			'script', 'embed', 'object', 'iframe', 'frame', 'frameset',
			'ilayer', 'layer', 'bgsound', 'title', 'base'
		);

		return $string;
	}
225285
public static function underscore( $string ) {

        if ( !preg_match( '/[A-Z-]|::/' , $string ) ) return $string;

        $string = strtr( $string , [ '::' => '/' , '-' => '_' ] );

        $string = preg_replace( '/([A-Z\d]+)([A-Z][a-z])/' , '$1_$2' , $string );

        $string = preg_replace( '/([a-z\d])([A-Z])/' , '$1_$2' , $string );

        return strtolower( $string );

    }
943239
private String
sanitize(String str) {
	if (wordcase == CASE_UPPER)
		return str.toUpperCase();
	else if (wordcase == CASE_LOWER)
		return str.toLowerCase();
	return str;
}
519839
protected function sensible($string)
    {
        $string = preg_replace('`([A-Z])`', '-\1', $string);
        $string = str_replace(array('-', '_'), ' ', $string);

        return ucfirst(trim(strtolower($string)));
    }
313761
public static function obfuscate($string) {
        $string = (string) $string;
        $length = mb_strlen($string);
        $scrambled = '';

        if ($length > 0) {
            for ($i = 0; $i < $length; $i++) {
                $scrambled .= '&#' . ord($string[$i]) . ';';
            }
        }

        return $scrambled;
    }
937900
protected function doUnclassify($string)
    {
        $string = str_replace('\\', '_', $string);
        $parts = explode("_", $string);
        $parts = array_map([$this, "underscore"], $parts);

        return implode("-", $parts);
    }
688728
public static function slugify($string) {
        $string = strip_tags($string);
        $string = str_replace(['&amp;', '&'], 'and', $string);
        $string = str_replace('@', 'at', $string);

        // @codeCoverageIgnoreStart
        if (class_exists('Titon\G11n\Utility\Inflector')) {
            return \Titon\G11n\Utility\Inflector::slug($string);
        }
        // @codeCoverageIgnoreEnd

        return Inflector::slug($string);
    }
279968
protected function cleanExport($string)
    {
        $quote = '"';
        $slash = '\\';
        $newline = "\n";

        $replaces = array(
            "$slash" => "$slash$slash",
            "$quote" => "$slash$quote",
            "\t"     => '\t',
        );

        $string = str_replace(array_keys($replaces), array_values($replaces), $string);

        $po = $quote . implode("${slash}n$quote$newline$quote", explode($newline, $string)) . $quote;

        // remove empty strings
        return str_replace("$newline$quote$quote", '', $po);
    }
962538
private function stripAccents($string){
		$string = utf8_decode($string);
		$string = strtr($string,
						utf8_decode('Ã Ã¡Ã¢Ã£Ã¤Ã§Ã¨Ã©ÃªÃ«Ã¬Ã­Ã®Ã¯Ã±Ã²Ã³Ã´ÃµÃ¶Ã¹ÃºÃ»Ã¼Ã½Ã¿Ã€Ã�Ã‚ÃƒÃ„Ã‡ÃˆÃ‰ÃŠÃ‹ÃŒÃ�ÃŽÃ�Ã‘Ã’Ã“Ã”Ã•Ã–Ã™ÃšÃ›ÃœÃ�'),
						'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
		return utf8_encode($string);
	}
1346728
public static function cliMessage($string)
    {
        $preString = '  | ';
        if (is_array($string)) {
            echo $preString.implode("\n==> ", $string)."\n";
        } else {
            echo $preString.$string."\n";
        }
    }
298947
protected function clean($string)
    {
        $string = str_replace($this->getDelimiter(), '_', Container::underscore($string));
        // fixes underscores removed by the Container::underscore()
        $string = str_replace('.', '_', $string);
        $string = preg_replace('/[^A-Za-z0-9_]/', '', $string);
        
        return preg_replace('/_+/', '_', $string);
    }
45750
static public function sanitizeInjectively($string) {
        $sanitized = '';
        foreach (str_split($string) as $char) {
            $sanitized .= isset(self::$ALLOWED_CHARACTERS[$char]) ? $char : '='.base64_encode($char);
        }
        return $sanitized;
    }
900466
public static function decodeHtmlEntities($string)
  {
    // Entities-replacements
    $entities = array ("'&(quot|#34);'i",
                        "'&(amp|#38);'i",
                        "'&(lt|#60);'i",
                        "'&(gt|#62);'i",
                        "'&(nbsp|#160);'i",
                        "'&(iexcl|#161);'i",
                        "'&(cent|#162);'i",
                        "'&(pound|#163);'i",
                        "'&(copy|#169);'i");
                        
    $entitie_replacements = array ("\"",
                                   "&",
                                   "<",
                                   ">",
                                   " ",
                                   chr(161),
                                   chr(162),
                                   chr(163),
                                   chr(169));
    
  
    $string = preg_replace($entities, $entitie_replacements, $string);
    
    // Numeric haracter reference replacement (non-HEX), like &#64; => "@"
    $string = preg_replace_callback("/&#([0-9]{1,4});/ i", function($m) {return chr($m[1]);}, $string);
    
    // Numeric character reference replacement (HEX), like &#x2f; => "/"
    $string = preg_replace_callback("/&#x([0-9a-z]{2,4});/ i", function($m) {return chr(hexdec($m[1]));}, $string);
    
    return $string;
  }
1180613
private function formatStringAsTextBlock($string)
    {
        if (!is_string($string)) {
            return '';
        }

        $string = wordwrap($string, $this->maxLineLength - $this->prefixLength);

        $stringLines = explode(PHP_EOL, $string);
        foreach ($stringLines as &$line) {
            $line = str_repeat(' ', $this->prefixLength).$line;
        }

        $string = implode(PHP_EOL, $stringLines);

        // needed to remove the unnecessary prefix added to the first line
        $string = trim($string);

        return $string;
    }
970443
protected function sanitizeAccount($string)
    {
        static $crudeReplacements = [
            '.' => '',
            ' ' => '',
            'GIRO' => 'P',
        ];

        // crude IBAN to 'old' converter
        if (Mt940::$removeIBAN
            && preg_match('#[A-Z]{2}[\d]{2}[A-Z]{4}(.*)#', $string, $results)
            && !empty($results[1])
        ) {
            $string = $results[1];
        }

        $account = ltrim(
            str_replace(
                array_keys($crudeReplacements),
                $crudeReplacements,
                strip_tags(trim($string))
            ),
            '0'
        );
        if ($account !== '' && strlen($account) < 9 && strpos($account, 'P') === false) {
            $account = 'P' . $account;
        }

        return $account;
    }