preg_match_all string from file with value

2019-08-03 08:33发布

问题:

I need to search into file name lll.php about content of option by value

as

my file lll.php

<option value="n-7069">1</option>
<option value="n-7066">3</option>
<option value="n-7065">2</option>

I try this code but not work with me

my search code like n-7065

$ccc2=$rd33fddf33do['contery'] ; 

my file content value

$llll= file_get_contents('lll.php');

but it now work with me

preg_match_all('|<option *?</option>|ms', $llll, $matches);
foreach ($matches[0] as $select) {
    preg_match_all('|value='.$ccc2.'|', $select, $matches2);
    var_dump($matches2[1]);
}

回答1:

preg_match('#<option value="'.$ccc2.'"(.*?)>(.*?)</option>#im', $llll, $body); 
print_r($body[2]);