Page 1 of 1

Simple Array Question

Posted: Fri Sep 01, 2006 10:45 am
by snowrhythm
I'm still a bit of a newbster in programming and I can't find a function that will return the amount
of elements in an array. Like if the array is...

Code: Select all

array("shake", "my", "hand", "good", "sir");
...I would want this function to return "5".

Does anyone know of a function like this? If not, I could use a little help in learning how to write
one that would do this or manipulating other functions to get that value. I tried calling array_length()
and was pretty surprised to find that it didn't exist. Anyway, thanks in advance for any help.

Posted: Fri Sep 01, 2006 10:50 am
by malcolmboston

Code: Select all

$amount = count ($array);
would return 5 in your case

Posted: Fri Sep 01, 2006 10:55 am
by sweatje
Spend some time looking through http://php.net/array , it will be time well spent.

Posted: Fri Sep 01, 2006 11:08 am
by snowrhythm
Ah yes, the great inexhaustable php function site. Thanks malcolm and sweatje, I can use all the
resources I can get my hands on.