I think there's a mistake


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

$myName = "Dina";
    print substr($myName, 0, 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:


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.


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)


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.


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


No problem!


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