array_walk on class functions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

array_walk on class functions

Post by kendall »

Hi,

i am trying to do an array_walk on a class function

Code: Select all

array_walk($PublishVars->fields,array('DB', 'set_data_type_array'));
and i got an error
<b>Fatal error</b>: Using $this when not in object context in
the line that the error reffered to is

Code: Select all

function set_data_type_array($val){
        $val = $this->set_data_type($val);
    }
What is the correct syntax for array_walking class methods?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: array_walk on class functions

Post by Christopher »

Code: Select all

array_walk($PublishVars->fields,array($object, 'set_data_type_array'));
(#10850)
Post Reply