Re: any one can give an idea on this question ?
| From: | Arpad Ray | Date: | Thu, 26 Oct 2006 11:32:43 +0000 |
| Subject: | Re: any one can give an idea on this question ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-243648@lists.php.net to get a copy of this message | ||
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