how to pass more arguments to php array_walk?

It will only allow one argument for user data. I suggest passing your values as an array.

array_walk($addresses, array($this, '_handle'), array($a, $b));

The third parameter is a mixed data type. If you have many parameters, I would suggest putting them into an Array - perhaps an associative array to name them. You'd then pull them back out of that param:

$addresses = array('www.google.com', 'www.yahoo.com', 'www.microsoft.com');
$params = array('first','second');
array_walk($addresses, array($this, '_handle'), $params);

private function _handle($address,$count, $params) {
       echo $address; // www.google.com
       echo $params[0]; // first
       echo $params[1]; // second
}

Tags:

Php