Re: passing array to function?

From: Date: Wed, 07 Feb 2001 02:05:19 +0000
Subject: Re: passing array to function?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-38472@lists.php.net to get a copy of this message
On Wed, 7 Feb 2001 11:30, Jaxon wrote: > How do you write a function that takes an array as an argument? > > Could someone please point me at an example? > > Regards, > Jaxon Try this: <?php function show_elements($ary) { while(list($key,$val) = each($ary)) { echo "$key => $val<BR>"; } } $fruits=array("a"=>"apple","b"=>"banana","c"=>"cucumber","d"=>"apricot",); show_elements($fruits); ?> That's pretty much plagiarised from the array functions in the manual :-) -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#38472) next »