Skip to content

Instantly share code, notes, and snippets.

@atmd83
Created February 3, 2014 11:57
Show Gist options
  • Save atmd83/8782684 to your computer and use it in GitHub Desktop.
Save atmd83/8782684 to your computer and use it in GitHub Desktop.
Get first/last chars of a string in php
$string = "This is my string";
$firstTwo = substr($string, 0, 2); // first 2 letters of $string
$lastTwo = substr($string, -2); // last 2 letters of $string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment