Skip to content

Instantly share code, notes, and snippets.

@ma4a
Created May 4, 2013 12:29
Show Gist options
  • Select an option

  • Save ma4a/5517351 to your computer and use it in GitHub Desktop.

Select an option

Save ma4a/5517351 to your computer and use it in GitHub Desktop.
Only show the comments of a referred PHP file.
<?php
function commentworker($array, $s = '<br><br>')
{
if (is_array ($array))
{
$output = '';
foreach ($array as $v)
{
$output .= commentworker($v, $s);
}
return '<pre>'.$output.'</pre>';
}
else
{
return $array.$s;
}
}
$file = file_get_contents('../myFile.php');
$matches = array();
preg_match_all('/\/\*\*(.*)\*\//smU', $file, $matches);
$myoutput = commentworker($matches[0]);
echo $myoutput;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment