Adjust the length of strings in PHP
1 2 3 4 5 6 7 8 |
$var ="abcdefgh"; $var1 = substr($var, 3); //takes of first 3 $var1 is now "defgh" $var2 = substr_replace($var ,"",-3); //takes off last 3 $var2 is now "abcde" |
Get first 3 characters
1 2 3 4 |
$var3 = substr($var, 0, 3); $var3 is now "abc" |