I think there's a mistake


#1


it prints Di but if the first letter is 0 then it should print Din.


$myName = "Dina";
    print substr($myName, 0, 2);


#2

This is the correct code:
$myName = "Dina";
print substr($myName, 0, 3);

(Don't forget the indent)
Try it! It will print out Din.
I hope this helps!:grin:


#3

In that case it should print Dina because it says that the first letter is zero, the second is 1, the third is 2 etc.
I was wondering why it prints Di rather than Din.


#4

I haven't done PHP before but the whole 'index' thing seems similar so i reckon
D i n a
0 1 2 3
So maybe the last parameter is the number after the one you want to stop at? (if this makes sense)


#5

When you feel that your query has been solved i recommend you press the 'solved' button so other people know that it's been solved.


#6

Oooh ok. Yes you're right. Thank you!


#7

No problem!
:relaxed:


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.