Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8036505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:38:34+00:00 2026-06-05T02:38:34+00:00

My problem is this, i have a function which is stored in an array

  • 0

My problem is this, i have a function which is stored in an array which is a part of a class. I want to call a function from this array using call_user_func() however i can’t seem to figure out how to write this.

Calling a function from an array which is not in a class can be done like such.

 $thearray = array( 0 => 'funcone', 1 => 'functwo');
 call_user_func($thearray[0]);

However when i try to do this to an array which is in a class, it do sent work, i imagine because i need to reference the class somehow. I know that you can call a function from a class like this:

 call_user_func(array($myclass, 'funcone'));

But my question is how would a call a function from an array, which is within a class, by using call_user_func(); i hope somebody can help me with this, i have a feeling that it is just a matter of how its written.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:38:36+00:00Added an answer on June 5, 2026 at 2:38 am

    Assuming the array within the class is public, you can do:

    call_user_func(array($myclass, $myclass->thearray[0]));
    

    Did that answer your question?

    Update:

    I tried the following and it worked:

    <?php
    class Foo {
        public function bar() {
            echo "quux\n";
        }
    
        public $baz = array('bar');
    }
    
    $foo = new Foo();
    call_user_func(array($foo, $foo->baz[0]));
    
    shell$ php userfunc.php 
    quux
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem when call applet method from javascript.. I used this function
i have this strange problem with the PHP function CTYPE_ALNUM if i do: PHP:
i have a problem with this exception. I'm trying to make a function to
THIS IS THE FULL SCRIPT http://goo.gl/HoCxk I have a problem with this function: $('.message').click(function(){
Never ran into this problem with jQuery before. I have the following: $(document).ready(function() {
I have a problem i can't find the wrong in this function it sometimes
I have a problem with a jquery function. My HTML looks like this, I
I have this pattern written ^.*\.(?!jpg$|png$).+$ However there is a problem - this pattern
I have a function which must return one dimensional associate array, like $user_info[$index]=value where
hopefully someone can help me with this odd problem. I have a database which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.