I am calling this function which is modifying an array by reference:
function addWord(&$words, $wordIndex, $word)
{
$words[$wordIndex] = $word;
}
At th开发者_开发问答e function call,
addWord(&$words, $wordsIndex, $word);
($words is used only during the function call)
doesn't work. How do I make this or a similar functionality work? I want the addWord to be a separate function.
call your function without the reference operator:
$words = array();
addWord($words, $wordsIndex, $word);
You don't need to pass an ampersand in the function call; only in the function declaration.
精彩评论