note 126527 added to function.ctype-print

From: Date: Fri, 22 Oct 2021 14:22:24 +0000
Subject: note 126527 added to function.ctype-print
Groups: php.notes 
Request: Send a blank email to php-notes+get-217100@lists.php.net to get a copy of this message
You can use this function to detect if a string is "binary". <?php /** * Determine whether the given value is a binary string by checking to see if it contains only printable characters. * * @param string $value * * @return bool */ function isBinary($value): bool { // remove "unprintable" whitespace characters (tabs, newlines etc) $string = preg_replace('/\s/', '', (string)$value); return !empty($string) && !ctype_print($string); } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 86.132.86.51) ---- Manual Page -- https://php.net/manual/en/function.ctype-print.php Edit -- https://main.php.net/note/edit/126527 Del: integrated -- https://main.php.net/note/delete/126527/integrated Del: useless -- https://main.php.net/note/delete/126527/useless Del: bad code -- https://main.php.net/note/delete/126527/bad+code Del: spam -- https://main.php.net/note/delete/126527/spam Del: non-english -- https://main.php.net/note/delete/126527/non-english Del: in docs -- https://main.php.net/note/delete/126527/in+docs Del: other reasons-- https://main.php.net/note/delete/126527 Reject -- https://main.php.net/note/reject/126527 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217100) next »