ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

List and Details of Php String Functions

Updated on September 30, 2011

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.

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.

working

This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://corp.maven.io/privacy-policy

Show Details
Necessary
HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
LoginThis is necessary to sign in to the HubPages Service.
Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
AkismetThis is used to detect comment spam. (Privacy Policy)
HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
Features
Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
MavenThis supports the Maven widget and search functionality. (Privacy Policy)
Marketing
Google AdSenseThis is an ad network. (Privacy Policy)
Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
Index ExchangeThis is an ad network. (Privacy Policy)
SovrnThis is an ad network. (Privacy Policy)
Facebook AdsThis is an ad network. (Privacy Policy)
Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
AppNexusThis is an ad network. (Privacy Policy)
OpenxThis is an ad network. (Privacy Policy)
Rubicon ProjectThis is an ad network. (Privacy Policy)
TripleLiftThis is an ad network. (Privacy Policy)
Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
Statistics
Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
ClickscoThis is a data management platform studying reader behavior (Privacy Policy)