preg_match_all string from file with value

非 Y 不嫁゛ 提交于 2020-01-16 04:13:28

问题


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


来源:https://stackoverflow.com/questions/17039583/preg-match-all-string-from-file-with-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!