Using Arrays as parameters for functions
Posted: Fri Jul 26, 2002 6:32 am
Hello Everybody,
for my computer asset managment tool I've defined some container classes used transporting data from one class to another. For example there is a class host.
host.php look a little bit like the following:
Now I want to create a function called createHostTable which requires an array of hosts and creates a table with all the host details. The functions are in different files. My approach was the following:
How can I use arrays as parameters for functions? Is there any way to pass something like a pointer to an existing array?
Thanks in advance
Andy
for my computer asset managment tool I've defined some container classes used transporting data from one class to another. For example there is a class host.
host.php look a little bit like the following:
Code: Select all
class host {
getHostname() {
return $this->hostname;
}
}Code: Select all
function createHostTable ($hostsї]) {
$elements = count ($hostsї]);
for ($i = 0 ; $i < $elements) {
echo $hostsї$i]->getHostname;
echo $hostsї$i]->getAlias;
}
}Thanks in advance
Andy