public static function encodeArray(array $array, $func, $options = null)
{
if (!is_callable($func, false)) {
throw new \Kafka\Exception\Protocol('Encode array failed, given function is not callable.');
}
$arrayCount = count($array);
$body = '';
foreach ($array as $value) {
if (!is_null($options)) {
$body .= call_user_func($func, $value, $options);
} else {
$body .= call_user_func($func, $value);
}
}
return self::pack(self::BIT_B32, $arrayCount) . $body;
}