I have this question in PHP challenge, I don't know how they get . | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

I have this question in PHP challenge, I don't know how they get .

What is the output of this code? $s="Hi I love PHP."; $f=$s[strlen($s)-1]; echo $f;

26th Apr 2019, 7:59 PM
Siham
Siham - avatar
3 Answers
+ 13
output : P
14th May 2019, 7:27 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 11
The output is the last charater of the string: '.' strlen gives you the length of the string = 14 characters Because first character of the string is in position 0, last character is in position strlen($s)-1 $s[13] is character '.'
26th Apr 2019, 10:09 PM
Javier Felipe Toribio
Javier Felipe Toribio - avatar
+ 1
ami jainena
27th Apr 2019, 4:23 AM
MD Hossen
MD Hossen - avatar