I\'m using PHP\'s preg_match_all() to search a string imported using file_get_contents(). The regex returns matches but I would like to know at which line number those matches a
//Keep it simple, stupid $allcodeline = explode(PHP_EOL, $content); foreach ( $allcodeline as $line => $val ) : if ( preg_match("#SOMEREGEX#i",$val,$res) ) { echo $res[0] . '!' . $line . "\n"; } endforeach;