[PHP] any one can give an idea on this question ?
Hi, I just wondering this.. 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. Regards Sancar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] any one can give an idea on this question ?
Sancar Saran wrote: I just wondering this.. 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. Maybe it's just me, but I didn't see a question anywhere in that lot, just a statement of what you want to do. Seems obvious to me that you need to open each file, find assignments to the $arrHede array and pull out the values. Have you even tried to do that yet? We're not here to write scripts for you. Try it and come back if/when you have problems. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] any one can give an idea on this question ?
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
Re: [PHP] any one can give an idea on this question ?
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... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] any one can give an idea on this question ?
On Thu, October 26, 2006 6:36 am, Stut wrote: Sancar Saran wrote: I just wondering this.. 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. Maybe it's just me, but I didn't see a question anywhere in that lot, just a statement of what you want to do. Seems obvious to me that you need to open each file, find assignments to the $arrHede array and pull out the values. Have you even tried to do that yet? We're not here to write scripts for you. Try it and come back if/when you have problems. Something like: grep -r -e ^\s\$arrHede\[[a-z0-9_]+\]\s=\s.*$ . | php might do it for you... I'm horrible at bash/regexp and escaping, but you get the idea. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php