Php Find And Replace Matching Blocks Puzzle