-=[ Mr. Bumblebee ]=-
_Indonesia_

Path : /var/www/html/inc.bk/class/
File Upload :
Current File : /var/www/html/inc.bk/class/function.string.php

<?php

###########################################
// string
###########################################

	function str_seq_value ( $array , $text , $sign , $b_num = 1 , $return )
	{
		$array = explode( $sign , $array ) ;
		foreach ( $array as $val )
		{
			$return[$text . $b_num] = $val ;
			$b_num++;
		}
		return $return ;
	}

	function str_search ( $string , $begin_niddle , $end_niddle )
	{
		if ( is_numeric($begin_niddle)) $begin_number = $begin_niddle ;
		else
		{
			$begin_number = strpos( $string , $begin_niddle ) ;
			$begin_length = strlen( $begin_niddle ) ;
			$begin_number = $begin_number + $begin_length ;
		}
		if ( $begin_number === false ) return ;

		if ( is_numeric($end_niddle)) $end_number = $end_niddle ;
		else $end_number = strpos( $string , $end_niddle ) ;

		if ( $end_number === false )
			return substr ( $string , $begin_number ) ;
		else
		{
			$str_length = $end_number - $begin_number ;
			return substr ( $string , $begin_number , $str_length ) ;
		}
	}

	function str_extract ( $key_array , $val_array , $niddle )
	{
		$return_value = '' ;
		foreach ( $key_array as $key_is_num => $val_is_str )
		{
			if ( $val_is_str == $niddle )
				$return_value = $val_array[$key_is_num] ;
		}
		return $return_value ;
	}

	function str_rand ( $len = 4 , $mode = 'aA1' )
	{
		$haystack = '' ;
		$return_value = '' ;

		if ( strpos( $mode , 'a' ) !== false )
			$haystack.= 'abcdefghijklmnopqrstuvwxyz' ;
		if ( strpos( $mode , 'A' ) !== false )
			$haystack.= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ;
		if ( strpos( $mode , '1' ) !== false )
			$haystack.= '0123456789' ;

		for ( $i = 0 ; $i < $len ; $i++)
			$return_value.= $haystack{mt_rand(0,strlen($haystack)-1)} ;

		return $return_value ;
	}

	function str_convert ( $string )
	{
		$return_value = $string ;
		$return_value = str_ireplace('<script' , '<!--script' , $return_value ) ;
		$return_value = str_ireplace('/script>' , '/script-->' , $return_value ) ;
		$return_value = str_ireplace('<iframe' , '<!--iframe' , $return_value ) ;
		$return_value = str_ireplace('/iframe>' , '/iframe-->' , $return_value ) ;
		$return_value = str_ireplace('<frame' , '<!--frame' , $return_value ) ;
		$return_value = str_ireplace('/frame>' , '/frame-->' , $return_value ) ;
		$return_value = htmlspecialchars( $return_value , ENT_QUOTES ) ;
		$return_value = str_replace('$' , '&#36;' , $return_value ) ;
		$return_value = str_replace('<' , '&lt;' , $return_value ) ;
		$return_value = str_replace('>' , '&gt;' , $return_value ) ;
		return $return_value ;
	}

	function str_no_tag ( $string )
	{
		$return_value = html_entity_decode($string) ;
		$return_value = strip_tags($return_value) ;
		$return_value = str_replace("&nbsp;","",$return_value) ;
		return $return_value ;
	}

	function str_no_tag_ex ( $string )
	{
		// other :
		      $search = "'<[\/\!]*?[^<>]*?>'si" ;    // html tag remove
		      $replace = "" ;
		      $return_value = preg_replace( $search , $replace , $string ) ;
			  return $return_value ;
	}

	function str_no_script ( $string )
	{
		$search = "'<script[^>]*?>.*?</script>'si" ;  // script remove
		$replace = "" ;
		return preg_replace( $search , $replace , $string ) ;
	}

	function str_print ( $array )
	{
		echo '<pre>' ;
		print_r ( $array ) ;
		echo '</pre>' ;
		exit ;
	}

	function str_foreach ( $array , $niddle , $haystack )
	{
		if ( emptY($niddle)) return ;
		$match = '/(\$' . $niddle . '\[([\w]+)[^\]]*\])/' ;
		$html = $haystack ;

		if ( !is_array($array)) $array = array() ;

		preg_match_all ( $match , $html , $search_result ) ;

		foreach ( $search_result[0] as $key_is_tmp => $val_is_result )
		{
			$replace_value = '' ;
			foreach ( $array as $key_is_string => $val_is_string )
			{
				if ( '$' . $niddle . '[' . $key_is_string . ']' == $val_is_result )
				{
					$replace_value = $val_is_string ;
					break ;
				}
			}
			$html = str_replace( $val_is_result , $replace_value , $html ) ;
		}
		return $html ;
	}

	function str_cut ( $str , $len = 50 , $sign = '...' )
	{
		$str_len = strlen ($str) ;
		for ( $i = 0 ; $i < ( $len - 1 ) ; $i++)
			if ( ord(substr($str , $i , 1)) > 127) $i++ ;
		if ( $str_len > $len )
			$return_value = substr($str , 0, $i ) . $sign ;
		else
			$return_value = $str ;
		return $return_value ;
	}

	function str_cutByte ( $str , $len = 50 )
	{
		$str_len = strlen ($str) ;
		for ( $i = 0 ; $i < ( $len - 1 ) ; $i++)
			if ( ord(substr($str , $i , 1)) > 127) $i++ ;
		if ( $str_len > $len )
			$return_value = substr($str , 0, $i ) ;
		else
			$return_value = $str ;
		return $return_value ;
	}

	function str_secret ( $str , $max = 10 , $sign = '*' )
	{
		$str_len = strlen($str) ;
		for ( $i = 0 ; $i < $str_len; $i++)
		{
			if ( $i < $max )
			{
				if ( ord(substr($str, $i, 1)) > 127 )
				{
					$return_value.= substr($str , $i , 2) ;
					$i++;
				}
				else $return_value.= substr($str , $i , 1) ;
			}
			else
			{
					if ( ord(substr($str, $i, 1)) > 127)
					{
						$return_value.= $sign ;
						$i++;
					}
					else
						$return_value.= $sign ;
			}
		}
		return $return_value ;
	}

	function str_len ( $str ) {
		// ±ÛÀÚ¼ö±¸Çϱâ ( Çѱ۵µ 1±ÛÀڷΠħ )
		$str_len = strlen($str) ;
		$j = 0 ;
		for ( $i = 0 ; $i < $str_len; $i++)
		{
			if ( ord(substr($str, $i, 1)) > 127 ) $i++;
			$j++;
		}
		return $j ;
	}

	function str_len2 ( $str ) {
		$str_len = strlen($str) ;
		$j = 0 ;
		for ( $i = 0 ; $i < $str_len; $i++)
		{
			if ( ord(substr($str, $i, 1)) > 127 ) {$j++; $i++;}
			$j++;
		}
		return $j ;
	}

	function str_jsecret ( $str , $sign = '*' )
	{
		if ( str_len($str) == 1) return $sign ;
		$str_len = strlen($str) ;
		$j = 1 ;
		$return = '' ;
		for ( $i = 0 ; $i < $str_len; $i++)
		{
			$return_value = '' ;
			if ( ord(substr($str, $i, 1)) > 127 )
			{
				if ( $j%2 === 0 ) $return_value = $sign ;
				else $return_value = substr($str , $i , 2) ;
				$i++;
			}
			else
			{
				if ( $j%2 === 0 ) $return_value = $sign ;
				else $return_value = substr($str , $i , 1) ;
			}
			$j++;
			$return.= $return_value ;
		}
		return $return ;
	}

	function str_line_break ( $str , $max = 20 )
	{
		$str_len = strlen($str) ;
		$return_value = '' ;
		for ( $i = 0; $i < $str_len ; $i++)
		{
			if ( ord(substr($str , $i , 1)) > 127)
			{
				$return_value.= substr($str , $i , 2);
				$tmp = $i ;
				$i++ ;
				if (( $tmp%$max === 0 || $i%$max === 0) && !empty($i) && !emptY($tmp))
					$return_value.= '<br>' ;
			}
			else
			{
				$return_value.= substR($str , $i , 1) ;
				if ( $i%$max === 0 && !emptY($i))
					$return_value.= '<br>' ;
			}
		}
		$return_value = str_replace('&nbsp;' , ' ' , $return_value );
		return $return_value ;
	}

	function str_color ( $str , $key , $color = '#FF6600' )
	{
		$key = quotemeta($key) ;
		$return_value = eregi_replace( $key , '<span style="color:' . $color . '">' . $key . '</span>' , $str) ;
		return stripslashes( $return_value );
	}

	function str_mode ( $str , $mod = 'htxt' )
	{
		$return_value = $str ;
		$mod = strtolower($mod) ;
		switch ( $mod )
		{
			case 'text' :
								$return_value = str_replace('&gt;' , '>' , $return_value ) ;
								$return_value = str_replace('&lt;' , '<' , $return_value ) ;
								$return_value = str_replace('&#36;' , '$' , $return_value ) ;
								$return_value = html_entity_decode($return_value ) ;
								$return_value = str_replace('<' , '&lt;' , $return_value ) ;
								$return_value = str_replace(' ' , '&nbsp;' , $return_value ) ;
								$return_value = nl2br($return_value) ;
								break;
			case 'html' :
								$return_value = str_replace('&gt;' , '>' , $return_value ) ;
								$return_value = str_replace('&lt;' , '<' , $return_value ) ;
								$return_value = str_replace('&#36;' , '$' , $return_value ) ;
								$return_value = html_entity_decode($return_value ) ;
								break;
			case 'htxt' :
								$return_value = nl2br($return_value) ;
								break;
		}
		return $return_value ;
	}

	function str_empty ( $str )
	{
		if ( !ereg("([^[:space:]]+)" , $str)) return true ;
		else return false ;
	}

	function str_same ( $str1 , $str2 )
	{
		$aval1 = str_replace(' ' , '' , $str1) ;
		$aval2 = str_replace(' ' , '' , $str2) ;
		if ( $aval1 == $aval2) return true ;
		else return false ;
	}
	if(!function_exists('str_ireplace')){
	  function str_ireplace($search,$replace,$subject){
		$token = chr(1);
		$haystack = strtolower($subject);
		$needle = strtolower($search);
		while (($pos=strpos($haystack,$needle))!==FALSE){
		  $subject = substr_replace($subject,$token,$pos,strlen($search));
		  $haystack = substr_replace($haystack,$token,$pos,strlen($search));
		}
		$subject = str_replace($token,$replace,$subject);
		return $subject;
	  }
	}
	if (!function_exists("stripos")) {
	 function stripos($str,$needle) {
		 return strpos(strtolower($str),strtolower($needle));
	 }
	}

	if ( !function_exists("mb_strlen")) {
		function mb_strlen($str,$char = 'EUC-KR') {
			$str_len = strlen($str) ;
			$j = 0 ;
			for ( $i = 0 ; $i < $str_len; $i++)
			{
				if ( ord(substr($str, $i, 1)) > 127 ) $i++;
				$j++;
			}
			return $j ;
			//return strlen($str);
		}
	}

	function str_check_contents ( $str ) {
		$limit_char = '8¾ï,»õ³¢,°³»õ³¢,¼Ò»õ³¢,º´½Å,Áö¶ö,¾¾ÆÈ,½ÊÆÈ,´Ï±â¹Ì,Âî¶ö,Áö¶ö,½Ö³â,½Ö³ð,ºù½Å,Á¿±î,´Ï±â¹Ì,Á¿°°Àº°Ô,Àâ³ð,º­¾û½Å,¹Ùº¸»õ³¢,¾Ã»õ³¢,¾¾¹ß,¾¾ÆÈ,½Ã¹ú,¾¾¹ú,¶°±×¶ö,Á¿¹ä,ÃßõÀÎ,Ãßõid,Ãßõ¾ÆÀ̵ð,Ãßõid,Ãßõ¾ÆÀ̵ð,Ãß/õ/ÀÎ,½¦ÀÌ,µî½Å,½Î°¡Áö,¹ÌÄ£³ð,¹ÌÄ£³Ñ,Âî¶ö,Á×½À´Ï´Ù,´Ô¾Æ,´Ôµé¾Æ,¾¾¹ë³Ñ' ;
		$limit_chars = explode( ',' , $limit_char ) ;
		foreach ( $limit_chars as $val ) {
			if ( strpos ( $str , $val ) !== false ) {
				return true ;
			}
		}
		return false ;
	}

	function __unserialize ( $unserialize ) {
		$s_result = unserialize( $unserialize ) ;
		if ( $s_result === false ) {
			$tfarray = explode('{',$unserialize);
			$arrayinfo = explode(':',$tfarray[0]);
			$fcount = $arrayinfo[1] ;
			$arraycons = explode(';',$tfarray[1]);
			$result = array() ;
			$tcount = 0 ;
			for ( $i = 0 ; $i < $fcount ; $i++ ) {
				$tcount++ ;
				$tempvalues = explode( ':' , $arraycons[$tcount]);
				if ( substr($tempvalues[2],0,1) == '"' ) $tempvalues[2] = substr($tempvalues[2],1) ;
				if ( substr($tempvalues[2],-1,1) == '"' ) $tempvalues[2] = substr($tempvalues[2],0,-1) ;
				$result[$i] = $tempvalues[2] ;
				$tcount++ ;
			}
			return $result ;
		} else {
			return $s_result ;
		}
	}
?>

Copyright © 2017 || Recoded By Mr.Bumblebee