Sancar Saran wrote:
For example I had a several php pages. In this page there was an array named $arrHede

It has lots of values.

in index.php
$arrHede['antin']='yada';

in config.php
$arrHede['kuntin']='bada';

and so.

So I want to write a scrpit check all those files to get all $arrHede keys. And I do not want to include those files because of errors.
Scanning all the php files with regex is probably easiest, e.g.:

<?php
$keys = array();
foreach (glob('*.php') as $filename) {
   $contents = file_get_contents($filename);
if (preg_match_all('/\$arrHede\[([\'"])(.*?)\1/', $contents, $matches)) {
       $keys = array_merge($keys, $matches[2]);
   }
}
?>

Note that if your array keys contain escaped quotes, like ['foo\'bar'], the regex would need to be a bit more complex to allow for them.

Arpad

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to