How to get Last str...
 

[Solved] How to get Last string php code ?  


admin
Posts: 86
Admin
(@admin)
Member
Joined: 2 years ago

I need to get the last character of a string. Say I have "testers" as input string and I want the result to be "s". how can I do that in PHP?

1 Reply
admin
Posts: 86
Admin
(@admin)
Member
Joined: 2 years ago
<php? substr($string, -1) ?>

or

substr($string, -1) 

or

<php? echo substr($string, -1); ?>

 

or

 

<?php echo substr("testers", -1); echo mb_substr("testers", -1); ?>
Reply
Share:

Please Login or Register