0

I am trying to create a function within a loop and the name of the function needs to change for each time it is executed.

Here is the function that works:

add_filter("gform_field_value_eventname", 'populate_event');
        function populate_event($value){
        return $eventtitle;

but I need it to do something like this, where a variable could be added to the name of the function:

add_filter("gform_field_value_eventname", 'populate_event'.$y);
        function populate_event.$y($value){
        return $eventtitle;

Please could somebody point me in the right direction

Thanks

1 Answer 1

1

Try this instead (PHP 5 >= 5.3.0):

add_filter("gform_field_value_eventname", function($value){
    // code...
});

Make decisions internally, maybe depending on the $value.

Note: if it doesn't solve your problem please post more relevant code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.