Title: how to count array values php counting arrays holds variables script
Description: how to count array values php counting arrays holds variables script PHP
Tags: how, to, count, array, values, php, counting, arrays, holds, variables, script
Info: This Post Has Been Viewed 2741 Times SinceMon Feb 11, 2008 2:28 pm Author hostman With 2 Replies #5718

how to count array values php counting arrays holds variables script

how do i count the values of how many an array hold?

example:

$items = array("one", "two", "three", "four", "five", "six", "seven");
Comments (2)
View Top Comments
Leave Your Comments...
#1
lucas:
3 years ago
#40749
lucas Mon Feb 11, 2008 2:31 pm
that's very easy, just use the count() function in php..

you can do this:

PHP CODE:
<?
$items = array("one", "two", "three", "four", "five", "six", "seven");
echo count($items);
?>


OUTPUT
7
#2
Julius:
3 years ago
#41106
Julius Thu Feb 14, 2008 4:07 am
thanks this was helpful. i was storing some values in a comma separated list and converting it to an array with explode and didn't notice the comma at the end of the list nothing after it was being counted as an element and causing problems until i counted the number of value s in the array.
Share
| More