Skip to content
Advertisement

preg_match_all string from file with value

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]);
}

Advertisement

Answer

preg_match('#<option value="'.$ccc2.'"(.*?)>(.*?)</option>#im', $llll, $body); 
print_r($body[2]); 
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement