PHP String

22 functions

strlenstrlen(string $string): int

Get string length.

substrsubstr(string $string, int $offset, ?int $length): string

Return part of a string.

strposstrpos(string $haystack, string $needle, int $offset = 0): int|false

Find the position of the first occurrence of a substring in a string.

str_containsstr_contains(string $haystack, string $needle): bool

Determine if a string contains a given substring. (PHP 8+)

str_starts_withstr_starts_with(string $haystack, string $needle): bool

Checks if a string starts with a given substring. (PHP 8+)

str_ends_withstr_ends_with(string $haystack, string $needle): bool

Checks if a string ends with a given substring. (PHP 8+)

str_replacestr_replace(array|string $search, array|string $replace, string $subject): string

Replace all occurrences of the search string with the replacement string.

strtolowerstrtolower(string $string): string

Make a string lowercase.

strtoupperstrtoupper(string $string): string

Make a string uppercase.

trimtrim(string $string, string $characters = ' \n\r\t\v\x00'): string

앞뒤 공백(또는 지정 문자)을 제거합니다.

explodeexplode(string $separator, string $string, int $limit = PHP_INT_MAX): array

Split a string by a string.

implodeimplode(string $separator, array $array): string

Join array elements with a string.

sprintfsprintf(string $format, mixed ...$values): string

Return a formatted string.

nl2brnl2br(string $string): string

Inserts HTML line breaks before all newlines in a string.

htmlspecialcharshtmlspecialchars(string $string): string

Convert special characters to HTML entities.

strip_tagsstrip_tags(string $string): string

Strip HTML and PHP tags from a string.

str_padstr_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT): string

Pad a string to a certain length with another string.

str_repeatstr_repeat(string $string, int $times): string

Repeat a string.

ucfirstucfirst(string $string): string

Make a string's first character uppercase.

ucwordsucwords(string $string): string

Uppercase the first character of each word in a string.

str_splitstr_split(string $string, int $length = 1): array

Convert a string to an array.

number_formatnumber_format(float $num, int $decimals = 0): string

Format a number with grouped thousands.