Hello,
I'm trying to create a script that counts the number of people in an array by using a variable called "counter"
I am using functions to display the information, however it won't display..
<?php
function main()
{
$people = list_people();
echo 'There are currently: ' . $counter . 'Number of people\n\n';
foreach($people as $person)
{
echo $person . '\n\n';
}
}
function list_people()
{
global $counter;
$people = array ('Phillip', 'Mark', 'Oliver', 'Lucy');
foreach($people as $p)
{
$counter++;
}
return $people;
}
main();
?>
I can't return the $counter variables, as I'm already returning something else. Please, please help me.
Thanks.