Search This Blog

Apr 3, 2012

How to get Array Count on Javascript and PHP

Being a web developer, learning array is essential. You can use them as a list of values, a collection, stack and more. Array is usually use in Objective Oriented Programming but it is also helpful even in a simple program.

Ok, since array is a collection we need to know the number of item / values or shall we say the length of an array. Getting its length is useful in doing a loop statement.

Getting array length / count on PHP

$yourArray = array('value1, 'value2, 'value3');
echo count($yourArray);
PHP use the count() function to get the array length.

Getting Array length on Javascript

<script language="javascript" type="text/javascript">
var yourArray = new Array('value1', 'value2', 'value3');


SEO Training Ahmadabad said...

really good solutions for my searching and helpful in solving my problem in array counting in java script..

Link Building Services

IT Services said...

Thanks for the blog, i read your blog you providing us good information....