简体   繁体   中英

Php string get letter of index

I want to get the letter of a certain 'index' within a string. I know there is the strpos function but this is pretty much the opposite I want to do.

For instance:

$String = 'Hello';
echo getIndexOf(4, $String);

It would return 'o';

Is there any way I can do this? Thanks in advance!

You could simply do

$String[4] 

or use the substr function :

substr($String, 4, 1).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM