Using Arrays with String Functions

The function that you are about to examine counts the words, but it does more than that. It pieces together a string one word at a time. It uses a type of variable called an array. Arrays intimidate some people, but they are actually quite simple. Instead of filling variables one string at a time, arrays enable you to get a whole batch of strings and reference any of them.

Think of an array as if it were a group of cells in a spreadsheet. If you have information in cells A1 through A3, you have an array of cells. If A1 contained FirstName, A2 contained MiddleName, and A3 contained LastName, then you could reference the contents by clicking the appropriate cell. In much the same way, you could set up an array ...

Get Access 2002 Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.