Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

String functions

  • strcmp
  • strcasecmp
  • explode
  • implode
  • nl2br
  • file_get_contents
  • str_replace
  • iconv
  • urlencode

There are lots of string functions in PHP. Here are a few examples:

  • strcmp - compare two string returns, -1, 0 +1 based on order according to ASCII table
  • strcasecmp
  • explode - split string to elements and return an array
  • implode - join array to make a string
  • nl2br - new line to html-break
  • file_get_contents - read in a whole file without explicitely opening (slurp)
  • str_replace - replace characters in a string
  • iconv - convert between character encodings: iconv('ISO-8859-8', 'UTF-8', $str)
  • urlencode - when we are generating URLs some characters (e.g. space) need to be encoded