Reputation: 13224
Is there any easy way to read comment header from file (css/js/php)
like
/*
Script Name : somescript
Author : Me
Version : 1.1
*/
As simple key-value array?
Upvotes: 0
Views: 103
Reputation: 5622
Check out Tokenizer.
To get all the comments in a file named file.php you'd do:
$tokens = token_get_all(file_get_contents("file.php"));
$comments = array();
foreach($tokens as $token) {
if($token[0] == T_COMMENT || $token[0] == T_DOC_COMMENT) {
$comments[] = $token[1];
}
}
print_r($comments);
jQuery.get("file.css", null, function(data) {
var comments = data.match(/\/\*.*\*\//g);
for each (var c in comments)
alert(c);
});
Upvotes: 2