Re: any one can give an idea on this question ?
| From: | Sancar Saran | Date: | Thu, 26 Oct 2006 12:03:29 +0000 |
| Subject: | Re: any one can give an idea on this question ? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-243649@lists.php.net to get a copy of this message | ||
On Thursday 26 October 2006 14:32, Arpad Ray wrote:
> 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
Lots of thanks, that regex things my weakest area in that php
I owe you my friend :)
Regads
Sancar...