PHP String Functions

Funcion Descripcion Sintaxis
addcslashes() Returns a string with backslashes in front of the specified characters addcslashes(string,characters)
addslashes() Returns a string with backslashes in front of predefined characters addslashes(string)
bin2hex() Converts a string of ASCII characters to hexadecimal values bin2hex(string)
chop() Removes whitespace or other characters from the right end of a string chop(string,charlist)
chr() Returns a character from a specified ASCII value chr(ascii)
chunk_split() Splits a string into a series of smaller parts chunk_split(string,length,end)
convert_cyr_string() Converts a string from one Cyrillic character-set to another convert_cyr_string(string,from,to)
convert_uudecode() Decodes a uuencoded string convert_uudecode(string)
convert_uuencode() Encodes a string using the uuencode algorithm convert_uuencode(string)
count_chars() Returns information about characters used in a string count_chars(string,mode)
crc32() Calculates a 32-bit CRC for a string crc32(string)
crypt() One-way string hashing crypt(str,salt)
echo() Outputs one or more strings echo(strings)
explode() Breaks a string into an array explode(separator,string,limit)
fprintf() Writes a formatted string to a specified output stream fprintf(stream,format,arg1,arg2,arg++)
get_html_translation_table() Returns the translation table used by htmlspecialchars() and htmlentities() get_html_translation_table(function,flags,character-set)
hebrev() Converts Hebrew text to visual text hebrev(string,maxcharline)
hebrevc() Converts Hebrew text to visual text and new lines (\n) into <br> hebrevc(string,maxcharline)
hex2bin() Converts a string of hexadecimal values to ASCII characters hex2bin(string)
html_entity_decode() Converts HTML entities to characters html_entity_decode(string,flags,character-set)
htmlentities() Converts characters to HTML entities htmlentities(string,flags,character-set,double_encode)
htmlspecialchars_decode() Converts some predefined HTML entities to characters htmlspecialchars_decode(string,flags)
htmlspecialchars() Converts some predefined characters to HTML entities htmlspecialchars(string,flags,character-set,double_encode)
implode() Returns a string from the elements of an array implode(separator,array)
join() Alias of implode() join(separator,array)
lcfirst() Converts the first character of a string to lowercase lcfirst(string)
levenshtein() Returns the Levenshtein distance between two strings levenshtein(string1,string2,insert,replace,delete)
localeconv() Returns locale numeric and monetary formatting information localeconv()
ltrim() Removes whitespace or other characters from the left side of a string ltrim(string,charlist)
md5() Calculates the MD5 hash of a string md5(string,raw)
md5_file() Calculates the MD5 hash of a file md5_file(file,raw)
metaphone() Calculates the metaphone key of a string metaphone(string,length)
money_format() Returns a string formatted as a currency string money_format(string,number)
nl_langinfo() Returns specific local information nl_langinfo(element)
nl2br() Inserts HTML line breaks in front of each newline in a string nl2br(string,xhtml)
number_format() Formats a number with grouped thousands number_format(number,decimals,decimalpoint,separator)
ord() Returns the ASCII value of the first character of a string ord(string)
parse_str() Parses a query string into variables parse_str(string,array)
print() Outputs one or more strings print(strings)
printf() Outputs a formatted string printf(format,arg1,arg2,arg++)
quoted_printable_decode() Converts a quoted-printable string to an 8-bit string quoted_printable_decode(string)
quoted_printable_encode() Converts an 8-bit string to a quoted printable string quoted_printable_encode(string)
quotemeta() Quotes meta characters quotemeta(string)
rtrim() Removes whitespace or other characters from the right side of a string rtrim(string,charlist)
setlocale() Sets locale information setlocale(constant,location)
sha1() Calculates the SHA-1 hash of a string sha1(string,raw)
sha1_file() Calculates the SHA-1 hash of a file sha1_file(file,raw)
similar_text() Calculates the similarity between two strings similar_text(string1,string2,percent)
soundex() Calculates the soundex key of a string soundex(string)
sprintf() Writes a formatted string to a variable sprintf(format,arg1,arg2,arg++)
sscanf() Parses input from a string according to a format sscanf(string,format,arg1,arg2,arg++)
str_getcsv() Parses a CSV string into an array str_getcsv(string,separator,enclosure,escape)
str_ireplace() Replaces some characters in a string (case-insensitive) str_ireplace(find,replace,string,count)
str_pad() Pads a string to a new length str_pad(string,length,pad_string,pad_type)
str_repeat() Repeats a string a specified number of times str_repeat(string,repeat)
str_replace() Replaces some characters in a string (case-sensitive) str_replace(find,replace,string,count)
str_rot13() Performs the ROT13 encoding on a string str_rot13(string)
str_shuffle() Randomly shuffles all characters in a string str_shuffle(string)
str_split() Splits a string into an array str_split(string,length)
str_word_count() Count the number of words in a string str_word_count(string,return,char)
strcasecmp() Compares two strings (case-insensitive) strcasecmp(string1,string2)
strchr() Finds the first occurrence of a string inside another string (alias of strstr()) strchr(string,search,before_search);
strcmp() Compares two strings (case-sensitive) strcmp(string1,string2)
strcoll() Compares two strings (locale based string comparison) strcoll(string1,string2)
strcspn() Returns the number of characters found in a string before any part of some specified characters are found strcspn(string,char,start,length)
strip_tags() Strips HTML and PHP tags from a string strip_tags(string,allow)
stripcslashes() Unquotes a string quoted with addcslashes() stripcslashes(string)
stripslashes() Unquotes a string quoted with addslashes() stripslashes(string)
stripos() Returns the position of the first occurrence of a string inside another string (case-insensitive) stripos(string,find,start)
stristr() Finds the first occurrence of a string inside another string (case-insensitive) stristr(string,search,before_search)
strlen() Returns the length of a string strlen(string)
strnatcasecmp() Compares two strings using a "natural order" algorithm (case-insensitive) strnatcasecmp(string1,string2)
strnatcmp() Compares two strings using a "natural order" algorithm (case-sensitive) strnatcmp(string1,string2)
strncasecmp() String comparison of the first n characters (case-insensitive) strncasecmp(string1,string2,length)
strncmp() String comparison of the first n characters (case-sensitive) strncmp(string1,string2,length)
strpbrk() Searches a string for any of a set of characters strpbrk(string,charlist)
strpos() Returns the position of the first occurrence of a string inside another string (case-sensitive) strpos(string,find,start)
strrchr() Finds the last occurrence of a string inside another string strrchr(string,char)
strrev() Reverses a string strrev(string)
strripos() Finds the position of the last occurrence of a string inside another string (case-insensitive) strripos(string,find,start)
strrpos() Finds the position of the last occurrence of a string inside another string (case-sensitive) strrpos(string,find,start)
strspn() Returns the number of characters found in a string that contains only characters from a specified charlist strspn(string,charlist,start,length)
strstr() Finds the first occurrence of a string inside another string (case-sensitive) strstr(string,search,before_search)
strtok() Splits a string into smaller strings strtok(string,split)
strtolower() Converts a string to lowercase letters strtolower(string)
strtoupper() Converts a string to uppercase letters strtoupper(string)
strtr() Translates certain characters in a string strtr(string,from,to) or strtr(string,array)
substr() Returns a part of a string substr(string,start,length)
substr_compare() Compares two strings from a specified start position (binary safe and optionally case-sensitive) substr_compare(string1,string2,startpos,length,case)
substr_count() Counts the number of times a substring occurs in a string substr_count(string,substring,start,length)
substr_replace() Replaces a part of a string with another string substr_replace(string,replacement,start,length)
trim() Removes whitespace or other characters from both sides of a string trim(string,charlist)
ucfirst() Converts the first character of a string to uppercase ucfirst(string)
ucwords() Converts the first character of each word in a string to uppercase ucwords(string)
vfprintf() Writes a formatted string to a specified output stream vfprintf(stream,format,argarray)
vprintf() Outputs a formatted string vprintf(format,argarray)
vsprintf() Writes a formatted string to a variable vsprintf(format,argarray)
wordwrap() Wraps a string to a given number of characters wordwrap(string,width,break,cut)



۩_ Inicio
─►Siguiente Ejercicio
◄─Anterior Ejercicio