If you call a method inside an object that you must pass into an array, the first element is an object / context, and then the second should be a method:
A small example
function callback() {
the above is called a function and should be called like this: array_walk($array, 'callback');
class object() { public function callback() { } }
the above callback is called a method, it is almost the same as a function, but since it has a parent context inside the class, so it should be called like this:
$object = new object(); array_walk($array, array($object , 'callback'));
MySQLi is an object-oriented library, so after initializing the mysqli object, you must call the "method" as follows:
array_walk($array, array($msqli, 'real_escape_string'));
Also, as mentioned above, array_walk will move both the key and value into the mysql object, which will result in accurate escaping, you should use array_map to move only the values:
array_map($array, array($msqli, 'real_escape_string'));
source share