note 47964 rejected from function.array-walk by betz
| From: | betz@php.net | Date: | Tue, 07 Dec 2004 11:57:38 +0000 |
| Subject: | note 47964 rejected from function.array-walk by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-81486@lists.php.net to get a copy of this message | ||
Note Submitter: neo-blue at gmx dot net
----
I need to put all values of an array into one string line, separated with commas. That's what
I'm trying:
// inserting commas between array values
function array2string($item1, $key, &$string)
{
if ($string == '') {
$string = "$item1";
} else {
$string .= ",$item1";
}
}
// calling the function for each array value
array_walk($myarray, 'array2string', $myarray_string);
As you can see, I use pass-by-reference for the $myarray_string variable. The problem is that the
value is getting passed by I never get the value back from the function. Thus, the value of the
$myarray_string is still the same as before calling the "array2string".
Is this a PHP bug?