How to get the thired characters from the end of a string in PHP

3 Answers

0 votes
$ch = substr("php programming", -3, 1);

echo $ch;




/*
run:

i

*/

 



answered Mar 5, 2021 by avibootz
0 votes
$s = "php programming";

$ch = substr($s, strlen($s) - 3, 1);

echo $ch;




/*
run:

i

*/

 



answered Mar 5, 2021 by avibootz
0 votes
$s = "php programming";

$ch = $s[strlen($s) - 3];

echo $ch;




/*
run:

i

*/

 



answered Mar 5, 2021 by avibootz

Related questions

...