Monday, 19 August 2013

Isolating the value of an array variable in a string

Isolating the value of an array variable in a string

Let's say I have a line in a php file:
$config['fw_ls'] = 'some value';
I want to get the values between the quotes. What I tried are combinations
like:
preg_match('/\$config\[\'fw_ls\'\] = \'([^\'])*\';/',$sData,$aK);
var_dump($aK);
Sadly I can't seem to get the value between the quotes, in above example
it returns the character 't'. I really don't understand what I'm doing
wrong. I'd expect the regex would search starting from the quote and get
everything until it finds another quote. But that doesn't seem to be quite
right.
Any help would be appreciated.

No comments:

Post a Comment