angelcool Posted November 5, 2008 Share Posted November 5, 2008 Hello community, Does anyone know where exactly in the php manual is explained the next functionality: $string= 'abcdefg'; echo $string[4]; ...this works and outputs: 'e' this look like some sort of array, but I just can find it explained in the php manual. Any link for an exact explanation will be apreciated. Thank you. Angel Quote Link to comment Share on other sites More sharing options...
akitchin Posted November 5, 2008 Share Posted November 5, 2008 when used on a string, the index notation refers to the character in that string. 'e' is the 5th character in the string, which is index 4 (since indexes start at 0). $string[0] would be 'a', etc. Quote Link to comment Share on other sites More sharing options...
Michdd Posted November 5, 2008 Share Posted November 5, 2008 It's simple. It's outputting byte #4 in the string. But php starts counting from 0. Like: a = 0 b = 1 c = 2 d = 3 e = 4 In that example you gave. Quote Link to comment Share on other sites More sharing options...
angelcool Posted November 5, 2008 Author Share Posted November 5, 2008 Thank you for your fast reply. I do understand how this concept works, but would this be in the PHP manual? Quote Link to comment Share on other sites More sharing options...
akitchin Posted November 5, 2008 Share Posted November 5, 2008 it is, in the variables section. is there any particular reason you want to find it in the manual, despite understanding how it works? Quote Link to comment Share on other sites More sharing options...
angelcool Posted November 5, 2008 Author Share Posted November 5, 2008 there is not exactly a particular reason for this issue, I just wanted to find it in the manual that is pretty much it. perhaps self-satisfaction(maybe laziness to find it myself). i'll look in the variables section, thank you. = ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.