php - Isolating the value of an array variable in a string -


let's have line in php file:

$config['fw_ls'] = 'some value'; 

i want values between quotes. tried combinations like:

preg_match('/\$config\[\'fw_ls\'\] = \'([^\'])*\';/',$sdata,$ak); var_dump($ak); 

sadly can't seem value between quotes, in above example returns character 't'. don't understand i'm doing wrong. i'd expect regex search starting quote , until finds quote. doesn't seem quite right.

any appreciated.

try this:

$text = "\$config['fw_ls'] = 'some value';"; preg_match("#\\\$config\['fw_ls'\]\s*=\s*'([^']+)';#", $text, $match); print_r($match);  array (     [0] => $config['fw_ls'] = 'some value';     [1] => value ) 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -