CancelImage Upload

How to load and return the size of an array in PHP

Throughout your PHP programming career you will no doubt at some point (or rather at many frequent points) require a function to return the size of a given array. Here then is a code example making use of just such a function:

<?php

$names = array("Alice", "George", "John", "James", "Fred");

echo sizeof($names);

?>

How this function can be used does not really need much elaboration. Especially in regards to loops it can, or will, come in very handy:

<?php

$names = array("Alice", "George", "John", "James", "Fred");

for($i = 0; $i != sizeof($names); $i++)
{

     echo $names[$i]."<br>";

}

?>

For the JavaScript equivalent, read the following tutorial.

Login
Want to leave a comment?

No problem. Just enter your email and password below.


register | home | reminder

myDesignTool Networking • www.mydesigntool.cominfo@mydesigntool.com