hi all,
I cannot understand for what reason and how is used call_user_func_array
Can anyone explain me in a very simple manner what is call_user_func_array? and with examples if possible
Thanks in advance

thank you very much. but what advantages does this function have? if possible can you explain it in this example
and for what reason here used & operator

while ( $field = $meta->fetch_field() ) {

     $parameters[] = &$row[$field->name];



function read()
   $parameters = array();
   $results = array();

   $mysql = new mysqli('localhost', 'root', 'root', 'db') or die('There was a problem connecting to the database');
   $stmt = $mysql->prepare('SELECT body FROM posts') or die('Problem preparing query');

   $meta = $stmt->result_metadata();

   while ( $field = $meta->fetch_field() ) {

     $parameters[] = &$row[$field->name];

   call_user_func_array(array($stmt, 'bind_result'), $parameters);

   while ( $stmt->fetch() ) {
      $x = array();
      foreach( $row as $key => $val ) {
         $x[$key] = $val;
      $results[] = $x;

   return $results;


$results = read();
<!DOCTYPE html>

<html lang="en">
   <meta charset="utf-8">
<?php foreach ($results as $row) : ?>

   <p> <?php echo $row['body']; ?> </p>
<?php endforeach; ?>

thanks for attention

I realy do not know enough about php coding to give you an educated answer, but what I do know, is that call_user_func_array is useful when the number of parameters to a called function is variable or unknown, and other advantages is it also supports callbacks, so you can easily give a class function or object method to it.

For examples, see this page: