I am trying to get a full file structure using the RecursiveDirectoryIterator, RecursiveIteratorIterator and RegexIterator using the below code to get all the .php files in the system:
$directory = new RecursiveDirectoryIterator(realpath("/"));
$iterator = new RecursiveIteratorIterator($directory);
$regex = new RegexIterator($iterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);
But when I var_dump $regex, I get this:
object(RegexIterator)[4431]
public 'replacement' => null
What am I doing wrong here? It has me stumped...
NOTE
I got this code from: here