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
Post a Comment