3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = <<< TXT Blah Diddel Foo Bar1 Bar2 One XXY Password%1 = something Password%2 = other Password%3 = nuffing Completely different stuff here RandomS6}=2 User%1 = Henry User%2 = Marcus User%3 = SecretAdmin More stuff Even more stuff Loads of stuff TXT; $matches = []; $string = preg_replace_callback( '~^(?>User.+|Password.+|XXY)$~m', function ($match) use (&$matches) { @$matches[substr($match[0], 0, 4)] .= $match[0].PHP_EOL; return null; }, $input ); print_r(array_merge($matches, preg_split('/^\s+$/m', $string)));

preferences:
26.96 ms | 408 KiB | 5 Q