Reputation: 35347
I'm creating a debugging/doc script and I want to ignore all the standard comments but leave the PHPDoc in tact.
The code I was using was:
// Get file into an array line by line
$line = file($file);
// Trim all empty space and # or // comments
array_map(function($v) {
$v = trim($v);
$v = preg_split("/\/\/|#/", $v)[0];
return $v;
}, $line);
The problem being, this would still leave the multi-line C-style comments like:
/*
This
means
nothing
*/
So I believe I'll have to read in the entire file, find every /*
while ignoring /**
(PHPDoc) and removing everything until */
.
So the regex would need to be multi-line. I'm open to solutions using file()
but I think file_get_content()
would be more practical with the finding of C-style open and close comment tags on separate lines.
Upvotes: 1
Views: 59