$average ? 1 : 0; $one = $one << 1; } $hex = ''; foreach (str_split($binary, 4) as $binary) { $hex .= dechex(bindec($binary)); } return $hex; } }