sizeof ($myarray): Counts the number of elements in the array
For example 1:
<table border="8">
<tr><th> F1 Drivers</th></tr>
<?php
$f1_drivers = array ("Michael", "Mika", "Rubens", "Jacques", "David", "Harald");
if (sizeof($f1_drivers) <= "1")
echo "$PHP_SELF: Error, no array, now exiting...";
exit;
}
foreach ($f1_drivers as $value)
{
echo "<tr><td><b> $value </b></td></tr>";
}
?>
</table>
To declare a function, you must first have the word 'function' followed by the name you want to give the function. Next, pass in the parameters using round brackets. Inside the curly brackets can be any valid PHP statement(s). If a function is to return a value, then you can use the return function to return a value.
eg. function name ( value1, value2 ..)
{
any valid php statements;
return value;
}
To call a function from your scripts, simply give the function name and any values you are passing values in round brackets.
eg. name (value1, value2..);
Example 2:
(Print date and header)
<?php
function header($text)
{
echo (date ("L F d, Y"));
echo "<h1>$text</h1>";
echo "<hr>";
}
header ("Welcome To My Web Site ");
?>