Parsing file - locate and return matching comment for line (regex possible)
Posted on 2008-06-17
I have a PHP file that I want to read and parse to capture into a variable the matching comment (should it exist) for a matching array element.
So if this define is in the file I am parsing and I search on the array key 'most_viewed' - I would like to determine if a comment exits on that line and if so what the comment is.
$fp = fopen($file);
$contents = fread($fp);
.. now search for line matching array key and return comment if it exists.
$LANG_MGE01 = array (
'featured_series' => 'Featured Series',
'featured_episodes' => 'Featured Episodes',
'featured' => 'Featured',
'most_viewed' => 'xMost Viewed', // This is a test comment - most viewed