[eluser]sophistry[/eluser]
believe it or not, you are getting closer...
first of all, please post code with code blocks so it shows up with indents and syntax highlighting in the forum.
regex is a strange and wonderful thing. This is the thing that is "capturing" your function name.
The fact that the $matches_array has nothing in it means that something is wrong with the regex. It's probably the caret sign
that tells the regex to only look for the string "function" when it starts exactly at the start of a newline. probably not working because you have some spaces in there. try removing the caret and see what you get.
also, you don't need the $i - it isn't doing anything.
try this:
Code:
$helpers = glob(APPPATH.'helpers/*_helper.php');
foreach ($helpers as $line) {
// removed caret
preg_match('/function (.+?)\(/',$line,$matches_array);
echo var_dump( $matches_array );
}
if that regex doesn't work you can try this one:
Code:
preg_match('/function([^\(]+)/',$line,$matches_array);
that's a little different. it tells the regex engine to look for the string function and then captures anything up to the opening parentheses to the right of the function name.