PHP Get Character From String
To get sub string from a String we can use substr() method. Structure of this method is :
string substr (string $var, int $initial [, int $len] )
In the above example we want to get a sub string of variable $var, the initial index position is denoted by $initial and the length is given by $len, which is optional. If we don't mention the length PHP consider it as last value.
$string = "Goodbye, Varun!";
$a = substr($string, 0);
$b = substr($string, 1);
$c = substr($string, 2);
$d = substr($string, 50);
$e = substr($string, 5, 4);
$f = substr($string, 10, 1);
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.