Last active
January 29, 2016 01:13
-
-
Save inez/34c0b3be3f239caf454b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$txtOrig = $txt = file_get_contents('bad.txt'); | |
function test($str) { | |
preg_replace_callback("/test/u", function($matches) { return ''; }, $str); | |
return preg_last_error() === 4 /* PREG_BAD_UTF8_ERROR */; | |
} | |
$i = 0; | |
while ( strlen ( $txt ) > 0 ) { | |
$txt = substr($txt, 1); | |
if (test($txt) === false) { | |
break; | |
} | |
$i++; | |
} | |
echo substr($txtOrig, $i - 5, 15); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment