- Three weeks of hard work and I'm finally moving out of this hole. >>
- RT @ChrisPirillo: Is it just me, or is Twitter Suggestions virtually useless? It's showing me "famous" people I've done my best to ignor ... >>
- Fantastic uygur restaurant near Shinjuku http://yfrog.com/m97dqj >>
- Forget the mouse and god damn trackpad, I want a magic trackball!!! >>
- RT @mamachari: Clash of cultures or mere insensitivity? English teacher gets in hot water for playing hangman in Jpn school http://bit.l ... >>
Ran into something small that might be helpful for other PHP types. This isn’t rocket science, but I don’t see enough examples with static function calls for these functions.
array_walk lets you call a function that will be iterated over all members of an array. In my template class, I had to append some text to the front and back of a search variable. Instead of using the poorly performing foreach loop, I just ran the array_walk function and passed it a function that did the same thing.
array_walk($search, 'template_variable');
I decided that this was not what I wanted (since template_variable would be defined as a function in the global context), and I preferred putting related functions in the same class. I tried this:
array_walk($search, 'self::template_variable');
Of course, this didn’t work. array_walk is not a member of the Template class and as a result it just threw an error stating that “self::template_variable” didn’t exist.
array_walk($search, 'Template::template_variable');
This works fine.
-edit-
There’s something weird and inconsistent about all of this. template_variable works even while private, which throws everything out of wack.
Comments Off





