Jump to content

Recommended Posts

Hello i have two questions, regarding my problem.

1. I have a script which uses call_user_func_array , i heard it is not the best solution, here i post my script, please tell me what can i use instead of call_user_func_array, of course if the rumours are true that it is not the best solution.

 

2. My second question is that i get a warning message, if i turn error_reporting on:

'Warning: Wrong parameter count for array_intersect() in index.php on line xxx'

However the site displays properly, but i want to get rid of this error message, why is it appearing what is the problem.

 

My script:

 

$result = mysql_query("select id from table where word = '". $value ."');

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
                  $query_results[$value][] = $row[0];

            }
            
  $ids = call_user_func_array('array_intersect', $query_results);

Link to comment
https://forums.phpfreaks.com/topic/245954-hello-call_user_func_array-problem-help/
Share on other sites

Hello, thanks for the reply, i call where the line is in the script i posted "$ids = call_user_func_array('array_intersect', $query_results);"

So the error marks this  line...

 

And about call_user_func_array() , is it better to write an own function? I read that call_user_func_array() is substantially slower than calling a function directly.

well, thanks for that link, but of course i know http://php.net , my first thing,before asking anyone else is that i check the functions there. My question had nothing to do with "array_intersect"

I made it clear that i want to check if there is a replacement for call_user_function_array.

 

Anyway i will look for this in other sources which i found.

 

ps.: array_intersect_key is somwhat faster then array_intersect

There are two ways to attacking a problem of "is it faster to do...".

 

1.  You can believe someone when they tell you it is, and believe it is.

 

2. You can test it for yourself, and know it is.

 

If it were me, I would just call the function, as it is bound to be faster to call a function, vs. calling a function that calls a function.

well, thanks for that link, but of course i know http://php.net , my first thing,before asking anyone else is that i check the functions there. My question had nothing to do with "array_intersect"

I made it clear that i want to check if there is a replacement for call_user_function_array.

 

Anyway i will look for this in other sources which i found.

 

ps.: array_intersect_key is somwhat faster then array_intersect

and i answered that question in my first response.. why would you use a function to call a function that is already in the framework.. makes no sense

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.