- HubPages»
- Technology»
- Computers & Software»
- Computer Science & Programming»
- Programming Languages
List and Details of Php String Functions
Preface
Here, On this page, I'm publishing the list and details about all php string functions. String functions are the the most important part of every programming language including PHP and they holds the core position in PHP. Basically, PHP String functions simplifies the work of php programmers of manipulating and handling text data without writing a bunch of extra code in PHP Files.
Definition of String : A string is a data type used in programming, such as an integer and floating point unit, but is used to represent text rather than numbers. It is comprised of a set of characters that can also contain spaces and numbers - If specified correctly.
Here, Below is the full list of all those PHP string functions which are Supported in latest released version of PHP. String Functions List below has been ordered in alphabetical order.
Useful PHP Tutorial
- Learn About PHP function syntax
In this PHP Tutorial, I'll explain some of the basics about PHP function Syntax (or I say syntax of PHP function), Which one should have in understanding it without any confusion.
List of All PHP String Functions
Function
| Description
| Syntax
|
---|---|---|
addcslashes
| Quote string with slashes in a C style
| string addcslashes ( string $str , string $charlist )
|
addslashes
| Quote string with slashes
| string addslashes ( string $str )
|
bin2hex
| Convert binary data into hexadecimal representation
| string bin2hex ( string $str )
|
chop
| This function is an alias of rtrim().
| |
chr
| Return a specific character
| string chr ( int $ascii )
|
chunk_split
| Split a string into smaller chunks
| string chunk_split ( string $body [, int $chunklen = 76 [, string $end = "\r\n" ]] )
|
convert_cyr_string
| Convert from one Cyrillic character set to another
| string convert_cyr_string ( string $str , string $from , string $to )
|
convert_uudecode
| Decode a uuencoded string
| string convert_uudecode ( string $data )
|
convert_uuencode
| Uuencode a string
| string convert_uuencode ( string $data )
|
count_chars
| Return information about characters used in a string
| mixed count_chars ( string $string [, int $mode = 0 ] )
|
crc32
| Calculates the crc32 polynomial of a string
| int crc32 ( string $str )
|
crypt
| One-way string hashing
| string crypt ( string $str [, string $salt ] )
|
echo
| Output one or more strings
| void echo ( string $arg1 [, string $... ] )
|
explode
| Split a string by string
| array explode ( string $delimiter , string $string [, int $limit ] )
|
fprintf
| Write a formatted string to a stream
| int fprintf ( resource $handle , string $format [, mixed $args [, mixed $... ]] )
|
get_html_translation_table
| Returns the translation table used by htmlspecialchars and htmlentities
| array get_html_translation_table ([ int $table = HTML_SPECIALCHARS [, int $quote_style = ENT_COMPAT [, string $charset_hint ]]] )
|
hebrev
| Convert logical Hebrew text to visual text
| string hebrev ( string $hebrew_text [, int $max_chars_per_line = 0 ] )
|
hebrevc
| Convert logical Hebrew text to visual text with newline conversion
| string hebrevc ( string $hebrew_text [, int $max_chars_per_line = 0 ] )
|
html_entity_decode
| Convert all HTML entities to their applicable characters
| string html_entity_decode ( string $string [, int $quote_style = ENT_COMPAT [, string $charset = 'UTF-8' ]] )
|
htmlentities
| Convert all applicable characters to HTML entities
| string htmlentities ( string $string [, int $flags = ENT_COMPAT [, string $charset [, bool $double_encode = true ]]] )
|
htmlspecialchars_decode
| Convert special HTML entities back to characters
| string htmlspecialchars_decode ( string $string [, int $quote_style = ENT_COMPAT ] )
|
htmlspecialchars
| Convert special characters to HTML entities
| string htmlspecialchars ( string $string [, int $flags = ENT_COMPAT [, string $charset [, bool $double_encode = true ]]] )
|
implode
| Join array elements with a string
| string implode ( string $glue , array $pieces )
|
join
| Alias of implode
| string lcfirst ( string $str )
|
lcfirst
| Make a string's first character lowercase
| |
levenshtein
| Calculate Levenshtein distance between two strings
| int levenshtein ( string $str1 , string $str2 )
|
localeconv
| Get numeric formatting information
| array localeconv ( void )
|
ltrim
| Strip whitespace (or other characters) from the beginning of a string
| string ltrim ( string $str [, string $charlist ] )
|
md5_file
| Calculates the md5 hash of a given file
| string md5_file ( string $filename [, bool $raw_output = false ] )
|
md5
| Calculate the md5 hash of a string
| string md5 ( string $str [, bool $raw_output = false ] )
|
metaphone
| Calculate the metaphone key of a string
| string metaphone ( string $str [, int $phonemes = 0 ] )
|
money_format
| Formats a number as a currency string
| string money_format ( string $format , float $number )
|
nl_langinfo
| Query language and locale information
| string nl_langinfo ( int $item )
|
nl2br
| Inserts HTML line breaks before all newlines in a string
| string nl2br ( string $string [, bool $is_xhtml = true ] )
|
number_format
| Format a number with grouped thousands
| string number_format ( float $number [, int $decimals = 0 ] )
|
ord
| Return ASCII value of character
| int ord ( string $string )
|
parse_str
| Parses the string into variables
| void parse_str ( string $str [, array &$arr ] )
|
print
| Output a string
| int print ( string $arg )
|
printf
| Output a formatted string
| int printf ( string $format [, mixed $args [, mixed $... ]] )
|
quoted_printable_decode
| Convert a quoted-printable string to an 8 bit string
| string quoted_printable_decode ( string $str )
|
quoted_printable_encode
| Convert a 8 bit string to a quoted-printable string
| string quoted_printable_encode ( string $str )
|
quotemeta
| Quote meta characters
| string quotemeta ( string $str )
|
rtrim
| Strip whitespace (or other characters) from the end of a string
| string rtrim ( string $str [, string $charlist ] )
|
setlocale
| Set locale information
| string setlocale ( int $category , string $locale [, string $... ] )
|
sha1_file
| Calculate the sha1 hash of a file
| string sha1_file ( string $filename [, bool $raw_output = false ] )
|
sha1
| Calculate the sha1 hash of a string
| string sha1 ( string $str [, bool $raw_output = false ] )
|
similar_text
| Calculate the similarity between two strings
| int similar_text ( string $first , string $second [, float &$percent ] )
|
soundex
| Calculate the soundex key of a string
| string soundex ( string $str )
|
sprintf
| Return a formatted string
| string sprintf ( string $format [, mixed $args [, mixed $... ]] )
|
sscanf
| Parses input from a string according to a format
| mixed sscanf ( string $str , string $format [, mixed &$... ] )
|
str_getcsv
| Parse a CSV string into an array
| array str_getcsv ( string $input [, string $delimiter = ',' [, string $enclosure = '"' [, string $escape = '\\' ]]] )
|
str_ireplace
| Case-insensitive version of str_replace.
| mixed str_ireplace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
|
str_pad
| Pad a string to a certain length with another string
| string str_pad ( string $input , int $pad_length [, string $pad_string = " " [, int $pad_type = STR_PAD_RIGHT ]] )
|
str_repeat
| Repeat a string
| string str_repeat ( string $input , int $multiplier )
|
str_replace
| Replace all occurrences of the search string with the replacement string
| mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
|
str_rot13
| Perform the rot13 transform on a string
| string str_rot13 ( string $str )
|
str_shuffle
| Randomly shuffles a string
| string str_shuffle ( string $str )
|
str_split
| Convert a string to an array
| array str_split ( string $string [, int $split_length = 1 ] )
|
str_word_count
| Return information about words used in a string
| mixed str_word_count ( string $string [, int $format = 0 [, string $charlist ]] )
|
strcasecmp
| Binary safe case-insensitive string comparison
| int strcasecmp ( string $str1 , string $str2 )
|
strchr
| Alias of strstr
| |
strcmp
| Binary safe string comparison
| int strcmp ( string $str1 , string $str2 )
|
strcoll
| Locale based string comparison
| int strcoll ( string $str1 , string $str2 )
|
strcspn
| Find length of initial segment not matching mask
| int strcspn ( string $str1 , string $str2 [, int $start [, int $length ]] )
|
strip_tags
| Strip HTML and PHP tags from a string
| string strip_tags ( string $str [, string $allowable_tags ] )
|
stripcslashes
| Un-quote string quoted with addcslashes
| string stripcslashes ( string $str )
|
stripos
| Find position of first occurrence of a case-insensitive string
| int stripos ( string $haystack , string $needle [, int $offset = 0 ] )
|
stripslashes
| Un-quotes a quoted string
| string stripslashes ( string $str )
|
stristr
| Case-insensitive strstr
| string stristr ( string $haystack , mixed $needle [, bool $before_needle = false ] )
|
strlen
| Get string length
| int strlen ( string $string )
|
strnatcasecmp
| Case insensitive string comparisons using a "natural order" algorithm
| int strnatcasecmp ( string $str1 , string $str2 )
|
strnatcmp
| String comparisons using a "natural order" algorithm
| int strnatcmp ( string $str1 , string $str2 )
|
strncasecmp
| Binary safe case-insensitive string comparison of the first n characters
| int strncasecmp ( string $str1 , string $str2 , int $len )
|
strncmp
| Binary safe string comparison of the first n characters
| int strncmp ( string $str1 , string $str2 , int $len )
|
strpbrk
| Search a string for any of a set of characters
| string strpbrk ( string $haystack , string $char_list )
|
strpos
| Find position of first occurrence of a string
| int strpos ( string $haystack , mixed $needle [, int $offset = 0 ] )
|
strrchr
| Find the last occurrence of a character in a string
| string strrchr ( string $haystack , mixed $needle )
|
strrev
| Reverse a string
| string strrev ( string $string )
|
strripos
| Find position of last occurrence of a case-insensitive string in a string
| int strripos ( string $haystack , string $needle [, int $offset = 0 ] )
|
strrpos
| Find the position of the last occurrence of a substring in a string
| int strrpos ( string $haystack , string $needle [, int $offset = 0 ] )
|
strspn
| Finds the length of the initial segment of a string consisting entirely of characters contained within a given mask.
| int strspn ( string $subject , string $mask [, int $start [, int $length ]] )
|
strstr
| Find first occurrence of a string
| string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] )
|
strtok
| Tokenize string
| string strtok ( string $str , string $token )
|
strtolower
| Make a string lowercase
| string strtolower ( string $str )
|
strtoupper
| Make a string uppercase
| string strtoupper ( string $string )
|
strtr
| Translate characters or replace substrings
| string strtr ( string $str , string $from , string $to )
|
substr_compare
| Binary safe comparison of two strings from an offset, up to length characters
| int substr_compare ( string $main_str , string $str , int $offset [, int $length [, bool $case_insensitivity = false ]] )
|
substr_count
| Count the number of substring occurrences
| int substr_count ( string $haystack , string $needle [, int $offset = 0 [, int $length ]] )
|
substr_replace
| Replace text within a portion of a string
| mixed substr_replace ( mixed $string , mixed $replacement , mixed $start [, mixed $length ] )
|
substr
| Return part of a string
| string substr ( string $string , int $start [, int $length ] )
|
trim
| Strip whitespace (or other characters) from the beginning and end of a string
| string trim ( string $str [, string $charlist ] )
|
ucfirst
| Make a string's first character uppercase
| string ucfirst ( string $str )
|
ucwords
| Uppercase the first character of each word in a string
| string ucwords ( string $str )
|
vfprintf
| Write a formatted string to a stream
| int vfprintf ( resource $handle , string $format , array $args )
|
vprintf
| Output a formatted string
| int vprintf ( string $format , array $args )
|
vsprintf
| Return a formatted string
| string vsprintf ( string $format , array $args )
|
wordwrap
| Wraps a string to a given number of characters
| string wordwrap ( string $str [, int $width = 75 [, string $break = "\n" [, bool $cut = false ]]] )
|
Data Type Indicated before each function in syntax name represents the data type of Output i.e. result return by particular function.
So, that was the huge list of php string functions supported by latest version of PHP. Hope, You can easily navigate through all this php functions.