How To Count Elements In An Array Find How Many Values Arrays

Mobile
feeds
Welcome Login | Register

How To Count Elements In An Array Find How Many Values Arrays
  Forums Index
      » PHP Forums
        » » How To Count Elements In An Array Find How Many Values Arrays



How To Count Elements In An Array Find How Many Values Arrays
Post Description:
Post Tags: how, to, count, elements, in, an, array, find, how, many, values, arrays, free php support, php scripts, php questions, php answers, programming, codes, scripts
This Post Has Been Viewed 551 Times Since Fri Feb 22, 2008 7:57 pm Posted By hostman with 2 replies
How To Count Elements In An Array Find How Many Values Arrays
this is a good php function when you want to know how many elements are in an array.


PHP CODE
<?php
$a[0] = 1;
$a[1] = 3;
$a[2] = 5;
$result = count($a);
// $result == 3

$b[0] = 7;
$b[5] = 9;
$b[10] = 11;
$result = count($b);
// $result == 3

$result = count(null);
// $result == 0

$result = count(false);
// $result == 1
?>


an easy one is this code also to help you explain how to use this function:

<?
$count = array('1','2','3');
echo '<h1>'.count($count).'</h1>';
?>

OUTPUT: 3

for more information about this function go to http://www.php.net/manual/en/function.count.php


Leave Your Comments






Share
URL:
You can use this HTML code to put it on your website to show your friends this wallpaper. Use this code on your profile like myspace, friendster, Facebook or others. Just Copy and Paste it in your HTML on your websites



Fourms BBCODE:
BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums





Comments and replies About How To Count Elements In An Array Find How Many Values Arrays




:: 1 :: Reply #42602 Reply By hostman On Fri Feb 22, 2008 8:04 pm
:: 2 :: Reply #76497 Reply By luis On Mon Oct 20, 2008 8:08 pm
thank you i was looking for php code to find the array count