PHP String Functions

Wednesday, 19 August 2015



Basically PHP came with some predefined string functions to manipulate or to do some required operation on strings.First we will discuss few about string and then we will move to strings functions present in PHP in details.

Strings:

  • A string is a series or sequence of characters. e.g "Hello World".
  • A character is same as a byte.
  • PHP supports 265 sets of character.
  • String can be as large as up to 2GB (i.e 2147483647 max)

Strings Functions:

In PHP there are total more than 98 string functions are present as predefine function. Following are the list, that can help you at the time of your project requirements.


  1. addcslashes : Quote string with slashes in a C style
  2. addslashes : Quote string with slashes
  3. bin2hex : Convert binary data into hexadecimal representation
  4. chop : Alias of rtrim
  5. chr : Return a specific character
  6. chunk_split : Split a string into smaller chunks
  7. convert_cyr_string : Convert from one Cyrillic character set to another
  8. convert_uudecode : Decode a uuencoded string
  9. convert_uuencode : Uuencode a string
  10. count_chars : Return information about characters used in a string
  11. crc32 : Calculates the crc32 polynomial of a string
  12. crypt : One:way string hashing
  13. echo : Output one or more strings
  14. explode : Split a string by string
  15. fprintf : Write a formatted string to a stream
  16. get_html_translation_table : Returns the translation table used by htmlspecialchars and htmlentities
  17. hebrev : Convert logical Hebrew text to visual text
  18. hebrevc : Convert logical Hebrew text to visual text with newline conversion
  19. hex2bin : Decodes a hexadecimally encoded binary string
  20. html_entity_decode : Convert all HTML entities to their applicable characters
  21. htmlentities : Convert all applicable characters to HTML entities
  22. htmlspecialchars_decode : Convert special HTML entities back to characters
  23. htmlspecialchars : Convert special characters to HTML entities
  24. implode : Join array elements with a string
  25. join : Alias of implode
  26. lcfirst : Make a string's first character lowercase
  27. levenshtein : Calculate Levenshtein distance between two strings
  28. localeconv : Get numeric formatting information
  29. ltrim : Strip whitespace (or other characters) from the beginning of a string
  30. md5_file : Calculates the md5 hash of a given file
  31. md5 : Calculate the md5 hash of a string
  32. metaphone : Calculate the metaphone key of a string
  33. money_format : Formats a number as a currency string
  34. nl_langinfo : Query language and locale information
  35. nl2br : Inserts HTML line breaks before all newlines in a string
  36. number_format : Format a number with grouped thousands
  37. ord : Return ASCII value of character
  38. parse_str : Parses the string into variables
  39. print : Output a string
  40. printf : Output a formatted string
  41. quoted_printable_decode : Convert a quoted:printable string to an 8 bit string
  42. quoted_printable_encode : Convert a 8 bit string to a quoted:printable string
  43. quotemeta : Quote meta characters
  44. rtrim : Strip whitespace (or other characters) from the end of a string
  45. setlocale : Set locale information
  46. sha1_file : Calculate the sha1 hash of a file
  47. sha1 : Calculate the sha1 hash of a string
  48. similar_text : Calculate the similarity between two strings
  49. soundex : Calculate the soundex key of a string
  50. sprintf : Return a formatted string
  51. sscanf : Parses input from a string according to a format
  52. str_getcsv : Parse a CSV string into an array
  53. str_ireplace : Case:insensitive version of str_replace.
  54. str_pad : Pad a string to a certain length with another string
  55. str_repeat : Repeat a string
  56. str_replace : Replace all occurrences of the search string with the replacement string
  57. str_rot13 : Perform the rot13 transform on a string
  58. str_shuffle : Randomly shuffles a string
  59. str_split : Convert a string to an array
  60. str_word_count : Return information about words used in a string
  61. strcasecmp : Binary safe case:insensitive string comparison
  62. strchr : Alias of strstr
  63. strcmp : Binary safe string comparison
  64. strcoll : Locale based string comparison
  65. strcspn : Find length of initial segment not matching mask
  66. strip_tags : Strip HTML and PHP tags from a string
  67. stripcslashes : Un:quote string quoted with addcslashes
  68. stripos : Find the position of the first occurrence of a case:insensitive substring in a string
  69. stripslashes : Un:quotes a quoted string
  70. stristr : Case:insensitive strstr
  71. strlen : Get string length
  72. strnatcasecmp : Case insensitive string comparisons using a "natural order" algorithm
  73. strnatcmp : String comparisons using a "natural order" algorithm
  74. strncasecmp : Binary safe case:insensitive string comparison of the first n characters
  75. strncmp : Binary safe string comparison of the first n characters
  76. strpbrk : Search a string for any of a set of characters
  77. strpos : Find the position of the first occurrence of a substring in a string
  78. strrchr : Find the last occurrence of a character in a string
  79. strrev : Reverse a string
  80. strripos : Find the position of the last occurrence of a case:insensitive substring in a string
  81. strrpos : Find the position of the last occurrence of a substring in a string
  82. strspn : Finds the length of the initial segment of a string consisting entirely of characters contained within a given mask.
  83. strstr : Find the first occurrence of a string
  84. strtok : Tokenize string
  85. strtolower : Make a string lowercase
  86. strtoupper : Make a string uppercase
  87. strtr : Translate characters or replace substrings
  88. substr_compare : Binary safe comparison of two strings from an offset, up to length characters
  89. substr_count : Count the number of substring occurrences
  90. substr_replace : Replace text within a portion of a string
  91. substr : Return part of a string
  92. trim : Strip whitespace (or other characters) from the beginning and end of a string
  93. ucfirst : Make a string's first character uppercase
  94. ucwords : Uppercase the first character of each word in a string
  95. vfprintf : Write a formatted string to a stream
  96. vprintf : Output a formatted string
  97. vsprintf : Return a formatted string
  98. wordwrap : Wraps a string to a given number of characters
Note:

Upto now we seen only the list of string functions, later in the same post we will see some string functions from above list in detail with real-time examples.



    No comments:

    Post a Comment

     
    About Contact Career Advertise Job Support Online Training Acardemic Projects Internship
    Copyright © 2016. [ info ].
    Design by Herdiansyah Hamzah. & Distributed by Free Blogger Templates
    Creative Commons License