<?php
 
    class text{
        
        public static function br2nl($text){
           $text = preg_replace("/(\r\n|\n|\r)/", "", $text);
           return preg_replace("=<br */?>=i", "\n", $text);
               return $text;
        }


        public function del_space( $item ){
            return str_replace( " " , "" , $item );
            
        }
        public function del_dublespace( $item ){
            return str_replace( "  " , " " , $item );
            
        }

		public static function textSCR( $text, $chars , $add = '' ){
			if (strlen( $text ) > $chars ) return substr($text, 0, strrpos(substr($text, 0, $chars), " ")). $add;
			else return $text;
		}
			
		public static function clearDiacritics($sText){  
		     $aReplacePL = array(  
		         'ą' => 'a', 'ę' => 'e', 'ś' => 's', 'ć' => 'c',  
		         'ó' => 'o', 'ń' => 'n', 'ż' => 'z', 'ź' => 'z', 'ł' => 'l',  
		         'Ą' => 'A', 'Ę' => 'E', 'Ś' => 'S', 'Ć' => 'C',  
		         'Ó' => 'O', 'Ń' => 'N', 'Ż' => 'Z', 'Ź' => 'Z', 'Ł' => 'L'  
		         );  
		       
		     return str_replace(array_keys($aReplacePL), array_values($aReplacePL), $sText);  
		 } 

		public static function inlink($sText,$space='-'){
			
			if(strlen($sText)>0){

			     $sText = self::clearDiacritics( $sText );  	
			     $sText = mb_strtolower($sText,'UTF-8');  
			     $sText = str_replace(' ', $space , $sText);  
			     $sText = preg_replace('/[^0-9a-z_\-\.]+/', '', $sText);  
			     $sText = preg_replace('/[\-]+/', '-', $sText);  
			     $sText = trim($sText, '-');  
			   
			     	return $sText; 				
			} else return null;
 
		}
    
    }


?>