PHP cli script for pattern matching