is_binary() in PHP 5
private function is_binary($string, $testLength = 256)
{
$testString = substr($string, 0, $testLength);
$testString = str_replace(array(chr(10), chr(13)), '', $testString);
return !ctype_print($testString);
}
Wow, there’s some activity on this blog! It’s sad that it’s all web-related. Lauren’s too busy finishing her course to do any designer tips or anything. Maybe next year… until then, enjoy this method of finding out if a string is binary or not without needing PHP 6.