Created
February 3, 2014 11:57
-
-
Save atmd83/8782684 to your computer and use it in GitHub Desktop.
Get first/last chars of a string in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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