PHP 클래스 luya\helpers\StringHelper

This class extends the {{yii\helpers\StringHelper}} class by some helpful methods.
부터: 1.0.0-beta7
저자: Basil Suter ([email protected])
상속: extends yii\helpers\StringHelper
파일 보기 프로젝트 열기: luyadev/luya 1 사용 예제들

공개 메소드들

메소드 설명
contains ( string | array $needle, string $haystack, boolean $strict = false ) : boolean Check whether a char or word exists in a string or not.
replaceFirst ( string $search, string $replace, string $subject ) : mixed Replace only the first occurance found inside the string.
typeCast ( mixed $string ) : mixed TypeCast a string to its specific types.

메소드 상세

contains() 공개 정적인 메소드

This method is case sensitive. The need can be an array with multiple chars or words who are going to look up in the haystack string. If an array of needle words is provided the $strict parameter defines whether all need keys must be found in the string to get the true response or if just one of the keys are found the response is already true.
부터: 1.0.0-rc1
public static contains ( string | array $needle, string $haystack, boolean $strict = false ) : boolean
$needle string | array The char or word to find in the $haystack. Can be an array to multi find words or char in the string.
$haystack string The haystack where the $needle string should be looked up.
$strict boolean If an array of needles is provided the $strict parameter defines whether all keys must be found ($strict = true) or just one result must be found ($strict = false).
리턴 boolean If an array of values is provided the response may change depending on $findAll

replaceFirst() 공개 정적인 메소드

The replace first method is *case sensitive*. php StringHelper::replaceFirst('abc', '123', 'abc abc abc'); // returns "123 abc abc"
부터: 1.0.0-rc1
public static replaceFirst ( string $search, string $replace, string $subject ) : mixed
$search string Search string to look for.
$replace string Replacement value for the first found occurrence.
$subject string The string you want to look up to replace the first element.
리턴 mixed Replaced string

typeCast() 공개 정적인 메소드

Arrays will passed to to the {{luya\helpers\ArrayHelper::typeCast}} class.
public static typeCast ( mixed $string ) : mixed
$string mixed The input string to type cast. Arrays will be passted to {{luya\helpers\ArrayHelper::typeCast}}.
리턴 mixed The new type casted value, if the input is an array the output is the typecasted array.