133

Built-In Functions
Substr

  • The substr() function returns the sub-string starting at a specified position (integer offset) in a target string

      $myString = "Hello World";
      $val = substr( $myString, 6 );
      # Yields "World"

  • An optional length parameter may be specified to shorten the extracted sub-string

      $myString = "Hello World";
      $val = substr( $myString, 6, 2 );
      # Yields "Wo"