Monday, February 14, 2011

Count-function-PHP

Assalamu'alaikum and selamat sejahtera,

Today,we will learn on how to count the element from your array using the code.So,the function is called count.Below is the example and some explanation.

the example:

<html>
<head>
<title>Count function</title>

<?PHP
$squad = array("alpha", "beta", "charlie", "delta");
$arr_count = count($squad);
print ("the number of element from your array=".$arr_count);
print("<br>");

for ($Number = 0; $Number < $arr_count; $Number++)
{print ("the element= ".$squad[$Number]."<BR>");}

?>
</head>
<body>
</body>
<html>

the explanation :

$arr_count = count($squad);

so we a variable to count the element in our array.In this case,we use "$arr_count" as a variable to count the element inside the array.So,it need to be declare that is equal to count($squad).So that,the count function will assign the value to $arr_count.


N\NOTE:try it!...need any help?please comment here...

No comments:

Post a Comment