Let’s use the text «Hello World» for the following example. The string consists of 11 characters (including the space character between the two words). The position of each character is shown here.
PHP, Java, C++, C#, Visual Basic, and Python numerates characters assuming that the first one is at position 0, the second one is at position 1, and so on. Please note that the space between the two words is considered a character as well.
Remember! A space is a character just like any other character. Just because nobody can see it, it doesn’t mean it doesn’t exist!
This article is taken from a book of mine. If you enjoyed it, please visit my author's page inand check out all of my books!