Re: Passing Array to Function ?
| From: | (Richard Lynch) | Date: | Sat, 01 Jul 2000 22:16:58 +0000 |
| Subject: | Re: Passing Array to Function ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-4309@lists.php.net to get a copy of this message | ||
In article <3958595B.A3D27234@innovativeinternet.com>,
jack@innovativeinternet.com (Jack Sasportas) wrote:
> I am having problems passing an array to a function.
> I could not find anything on the FAQ's or function info,although what I
> did find made it seem that you could pass an array to a function.
> I get parese errors....
function foo($array){
//This function assumes you pass in an array.
while (list($k, $v) = each($array)){
echo "$k ==> $v<BR>\n";
}
}
$bar = array('a' => 'apple', 'b' => 'banana',
'c' => 'coconut');
foo($bar);
You're probably trying to indicate that the array is an array somehow in
the function header. Don't. PHP is value-typed, not variable-typed: An
array knows it's an array because it is an array, not because some
function header or variable declaration told it it was.
--
Richard Lynch | If this was worth $$$ to you, buy a CD
US Customer Support Director | from one of the artists listed here:
Zend Technologies USA | http://www.L-I-E.com/artists.htm
http://www.zend.com | (this has nothing to do with Zend,
duh!)