PHP | String Functions

PHP String Functions


Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP String Functions.

The built-in PHP string functions allows you to access and manipulate strings.

Installation

There is no Installation needed to use these functions; they are part of the PHP core.


List of String Functions

The table below is a list of the built-in string functions supported in PHP. PHP - indicates the earliest versions of PHP having support for these functions -

Sr.NoFunction & DescriptionPHP
1addcslashes

It returns the string with blackslashes

4
2addslashes

It returns the string with blackslashes in front of predefined characters

4
3bin2hex

It is used to convert primary data to hexadecimal representation

4
4chop

It is used to removes whitespace

4
5chr

It returns the specific characters

4
6chunk split

It is used to split a string into chunks.

5
7convert cyr string

It is used to convert from one Cyrillic character set to another

4
8convert uudecode

It is used to decode a encoded string

5
9count chars

It is used to returns the information about character used in a string

4
10Crc32

It is used to calculates 32-bit CRC

4
11crypt

It is used to hashing the string

4
12Echo

It is give the output as one or more string

4
13explode

It is used to split a string by string

4
14fprintf

It is used to write a formatted string to a stream

5
15get html translation table

It returns the translation table used by htmlspecialchars() and htmlentities()

4
16hebrev

It is used to convert logical Hebrew text to visual text

4
17Hebrevc

It is used to convert logical Hebrew text to visual text with newline conversion

4
18hex2bin

It is used to convert a string of hexadecimal to ASCII character

4
19html entity decode

It is used to convert HTML entities to their application characters

4
20htmlentities

It is used to convert all applicable characters to Html entities

5.4
21html special chars decode

It is used to convert convert special HTML entities back to characters.

5.1.0
22htmlspecialchars

It is used to convert special characters to HTML entities

4
23implode

It is used to Join array elements with a string.

5
24join

It is alias of implode(), it returns string from the elements of an array

4
25lcfirst

It is used to make a string's first character should be lowercase.

5.3.0
26levenshtein

It is used calculate Levenshtein distance between two strings

4.0.1
27localeconv

It is used to get numeric formatting information

4
28ltrim

It used to strip whitespace or other characters from the beginning of a string

4
29md5_file

It is used to calculates the md5 hash of a given file

4
30md5

It is used to calculates the md5 hash of a string

4
31metaphone

It is used to calculates the metaphone key of a string

4
32money format

It is used to formats a number as a currency string

4.3.0
33nl langinfo

It has contained information about language and locale

4.3.0
34nl2br

It Inserts HTML line breaks before all newlines in a string

4
35number format

It is used to formats a number with grouped thousands

4
36ord

It returns ASCII Value of character

4
37parse str

It is used to parses the string into variables

4
38print

It returns output a string

4
39printf

It returns output a formatted string

4
40quoted printable decode

It is used to convert the quoted printable string to 8 bit string

4
41quoted printable decode

It is used to convert the quoted printable string to 8 bit string

4
42quoted printable encode

It is used to convert 8 bit string to the quoted printable string

4
43quotemeta

It is used to quote meta characters

4
44rtrim

It is used to remove the white spaces from end of the string

4
45setlocale

It is used to set locale information

4
46sha1 file

It is used to calculate the sha1 hash of a file

4
47sha1

It is used to calculate the sha1 hash of a string

4
48similar text

It is used to calculate the similarity between two strings

4
49soundex

It is used to calculate the soundex key of string

4
50sprintf

It is used to a formatted string

4
51str getcsv

It is used to parse parse a CSV string into array

4
52str ireplace

It is used to replace the characters with some other characters

5
53str pad

It is used to pads a string to a new length.

4.0.1
54str repeat

It is used to repeat a string

4
55str replace

It is used to replace the string with another string

4
56str rot13

It is used to perform the rot13 transform on a string

4
57str shuffle

It is used to randomly shuffles a string

4.3.0
58str split

It is used to convert a string to an array

5
59str word count

It returns information about words used in a string

5
60strcasecmp

It is used to compare two strings

4
61strchr

It is used to searches for the first occurrence of a string inside another

4
62strcmp

It is used to compare two strings

4
63strcoll

It is used to compare two strings based on locale

4.0.5
64strcspn

It returns number of characters find in a string before any part of the specified characters are found.

4
65strip tags

It is used to string HTML and PHP tags from a string.

4
66stripcslashes

It is used to removes backslashes

4
67stripos

It is used to find the position of first occurrence of a string inside the another string

4
68stripslashes

It is used to un-quoted a quoted string

4
69stristr

It is used searches for the first occurrence of a string inside another string.

4
70strlen

It is used get string length.

4
71strnatcasecmp

It is used compare two strings with a natural algorithm.

4
72strnatcmp

It is used compare two strings with a natural order algorithm.

4
73strncasecmp

It is used compare two strings.

4
74strncmp

It is used compare first n character.

4
75strpbrk

It is used search's a string for a specific character.

5
76strpos

It is used to find the position of first occurrence of a string inside another string.

4
77strrchr

It is used to find the last occurrence of a character in a string.

4
78strrev

It is used to reverse a string.

4
79strripos

It is used find the position of the last occurrence of a string inside the another string

5
80strspn

It returns number of characters found in the string from the charlist parameter.

4
81strstr

It is used to find the first occurrence of a string

4
82strtok

It is a tokenize string

4
83strtolower

It used to make a string lower case

4
84strtoupper

It used to make a string upper case

4
85strtr

It used to translates character or replace substring

4
86substr_compare

It used to compare two string format with a specific start position

4
87substr_count

It used to count the number of sub strings

4
88substr_replace

It used to replace the part of string with another string

4
89substr

It used to return a part of a string

4
90trim

It used to remove the whitespaces and other characters

4
91ucfirst

It used to convert the first character of a string to upper case

4
92ucwords

It used to convert the first character of a string to upper case in each string

4
93vfprintf

It used to convert formatted string to specific output

5
94vprintf

It used to convert string to formatted string

4.1
95vsprintf

It returns the formatted string

4.1
96wordwrap

It used to convert the long words to be broken and its arrange to the next line

4.0.2

In our subsequent tutorials, we are going to be discussing about the above listed string functions.


Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we are going to be discussing about PHP addcslashes() Function.

Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.