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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to