PHP Pass by reference
Posted
by Salil
on Stack Overflow
See other posts from Stack Overflow
or by Salil
Published on 2010-05-20T15:45:40Z
Indexed on
2010/05/20
15:50 UTC
Read the original article
Hit count: 118
php
I am calling this function which is modifying an array by reference:
function addWord(&$words, $wordIndex, $word) { $words[$wordIndex] = $word; }
At the 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.
© Stack Overflow or respective owner