Built-in Functions

Extracting or Replacing Substrings #

Single characters can be extracted using array (square brace) syntax as well as curly brace syntax. These two syntaxes will only return a single character from the string. If we need more than one character, we have to use the in-built substr function.

Note: Strings, like everything in PHP, are 0-indexed, i.e., their first character is at index 0.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy