this is the php script you need:
<?php //remove comments $Text = php_strip_whitespace("your_constants_file.php"); $Text = str_replace("<?php","",$Text); $Text = str_replace("<?","",$Text); $Text = str_replace("?>","",$Text); $Lines = explode(";",$Text); $Constants = array(); //extract constants from php code foreach ($Lines as $Line) { //skip blank lines if (strlen(trim($Line))==0) continue; $Line = trim($Line); //skip non-definition lines if (strpos($Line,"define(")!==0) continue; $Line = str_replace("define(\"","",$Line); //get definition name & value $Pos = strpos($Line,"\",\""); $Left = substr($Line,0,$Pos); $Right = substr($Line,$Pos+3); $Right = str_replace("\")","",$Right); $Constants[$Left] = $Right; } echo "<pre>"; var_dump($Constants); echo "</pre>"; ?>
The result will be something like this:
array(5) { ["_SEARCH"]=> string(6) "Search" ["_LOGIN"]=> string(5) "Login" ["_WRITES"]=> string(6) "writes" ["_POSTEDON"]=> string(9) "Posted on" ["_NICKNAME"]=> string(8) "Nickname" }
source share