I've been wondering if its feasible to make a php based core function only matching program. I dont want to use regex but make a custom matching function which could be implemented in a custom parser for xml. My ideas so far is to use file_get_contents() to provide the file as a source, then get the full length of characters of the file and then iterate using a for loop to search for every matching instance of the needle in the haystack. Any ideas how one would go about doing this with the ability to tokenize then matches? I know reinventing the wheel but regex can be complicated and does not suit context-free grammar parsing. The parser in question would read a files, transform it into php code thats serialized when its stored and then either matches the instances of the elements of builds a php code tree view of the xml doc.