menntarra_34 Posted August 29, 2011 Share Posted August 29, 2011 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); Quote Link to comment https://forums.phpfreaks.com/topic/245954-hello-call_user_func_array-problem-help/ Share on other sites More sharing options...
AyKay47 Posted August 29, 2011 Share Posted August 29, 2011 1. you can use call_user_func() or simply write the actual function and pass the arguments.. 2. array_intersect() expects at least 2 parameters.. I would need to see where you call it to find a solution Quote Link to comment https://forums.phpfreaks.com/topic/245954-hello-call_user_func_array-problem-help/#findComment-1263158 Share on other sites More sharing options...
menntarra_34 Posted August 29, 2011 Author Share Posted August 29, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/245954-hello-call_user_func_array-problem-help/#findComment-1263192 Share on other sites More sharing options...
AyKay47 Posted August 29, 2011 Share Posted August 29, 2011 array_intersect is a predefined PHP array and cannot be used as a custom function.. array_intersect Quote Link to comment https://forums.phpfreaks.com/topic/245954-hello-call_user_func_array-problem-help/#findComment-1263194 Share on other sites More sharing options...
menntarra_34 Posted August 29, 2011 Author Share Posted August 29, 2011 oh i understand, i found why my "warning" message appear. What i still ask if there is a more appropriate, faster way of doing array_intersect other than the "call_user_function_array" way. Quote Link to comment https://forums.phpfreaks.com/topic/245954-hello-call_user_func_array-problem-help/#findComment-1263250 Share on other sites More sharing options...
AyKay47 Posted August 29, 2011 Share Posted August 29, 2011 DID YOU NOT CLICK ON THE LINK I POSTED. Quote Link to comment https://forums.phpfreaks.com/topic/245954-hello-call_user_func_array-problem-help/#findComment-1263251 Share on other sites More sharing options...
menntarra_34 Posted August 29, 2011 Author Share Posted August 29, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/245954-hello-call_user_func_array-problem-help/#findComment-1263276 Share on other sites More sharing options...
jcbones Posted August 29, 2011 Share Posted August 29, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/245954-hello-call_user_func_array-problem-help/#findComment-1263320 Share on other sites More sharing options...
AyKay47 Posted August 30, 2011 Share Posted August 30, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/245954-hello-call_user_func_array-problem-help/#findComment-1263459 Share on other sites More sharing options...
menntarra_34 Posted August 30, 2011 Author Share Posted August 30, 2011 Okay, thanks, question was stupid really Thanks for taking your time! Quote Link to comment https://forums.phpfreaks.com/topic/245954-hello-call_user_func_array-problem-help/#findComment-1263468 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.