array_walk with Class Level Function
Posted: Thu Jun 14, 2007 3:43 am
From inside a class, can array_walk() take a class level function as an argument? I know it can call a function outside of the class, but that seems untidy.
I also tried "\$this->sortIntoLists" and "$this->sortIntoLists" with the same error message.
Code: Select all
class SomeClass
{
private function sortIntoLists($value, $key)
{
echo "Key $key Value $value <br />";
}
private function processText()
{
// Break the text into a word array with the index as their positions
$this->mArrayAllWords = str_word_count($this->mTextForAnalysis, 2);
// Walk through the array and sort the words into the appropriate lists
array_walk($this->mArrayAllWords, "sortIntoLists"); // **** Function does not exist! ****
}
}