PHP字符串操作函数归纳

PHP 字符串函数是 PHP 核心的组成部分。

最常用函数:

  1. substr
  2. substr_compare
  3. substr_count
  4. substr_replace
  5. trim
  6. ucfirst
  7. ucwords
  8. strlen
  9. strcmp
  10. echo
  11. explode
  12. join
  13. ltrim
  14. md5
  15. ord
  16. print
  17. printf
  18. rtrim
  19. addslashes
  20. strtolower
  21. strtoupper
  22. strrev
  23. strstr
  24. strpos
  25. str_replace
  26. str_repeat
  27. str_shuffle
  28. str_split
  29. strcasecmp
  30. strchr strstr的别名
  31. strcmp
  32. addcslashes
  33. chop
  34. chr
  35. crc32
  36. crypt
  37. nl2br
  38. parse_str
  39. htmlspecialchars
  40. implode
  41. strip_tags
  42. stripcslashes
  43. stripslashes
  44. str_pad
  45. str_ireplace
  46. htmlentities

比较:

  1. strcoll
  2. strnatcasecmp
  3. strnatcmp
  4. strncasecmp
  5. strncmp

格式化:

  1. fprintf
  2. money_format
  3. number_format
  4. sprintf
  5. vfprintf
  6. vprintf
  7. vsprintf

编码:

  1. convert_uudecode
  2. convert_uuencode
  3. str_rot13

查找:

  1. strcspn
  2. stristr
  3. strpbrk
  4. stripos
  5. strrchr
  6. strripos
  7. strrpos

其他:

  1. bin2hex
  2. chunk_split
  3. convert_cyr_string
  4. count_chars
  5. get_html_translation_table
  6. hebrev
  7. hebrevc
  8. hex2bin
  9. html_entity_decode
  10. htmlspecialchars_decode
  11. lcfirst
  12. levenshtein
  13. localeconv
  14. md5_file
  15. metaphone
  16. nl_langinfo
  17. quoted_printable_decode
  18. quoted_printable_encode
  19. quotemeta
  20. setlocale
  21. sha1
  22. sha1_file
  23. similar_text
  24. soundex
  25. sscanf
  26. str_getcsv
  27. str_word_count
  28. strspn
  29. strtok
  30. strtr