= 0xC0 ) { $need = $b >= 0xF0 ? 4 : ( $b >= 0xE0 ? 3 : 2 ); return $i < $need ? $i : 0; } } return 0; } /** * Whether the first bytes look like a spreadsheet or archive instead of text (XLSX, XLS, ZIP). * * @param string $head First bytes. * @return bool */ public static function looksLikeSpreadsheet( string $head ): bool { return 0 === strncmp( $head, "PK\x03\x04", 4 ) || 0 === strncmp( $head, "\xD0\xCF\x11\xE0", 4 ); } }