I have one page, there would be have some regex work. cause the regex rule would be added or removed in the future. I'd like to write them into an out file. cause the here regex rule is very long, in my way i wrote there into a json data, but the php variable
is un-worked. Is there anyone could give me some good way for a work solution? Thanks.
json.txt
$json=<<<'EOT'
[
{
"a": "!preg_match('@www\\.aaa\\.com@',$url,$match)&&!preg_match('@www\\.bbb\\.com@',$url,$match)&&!preg_match('@www\\.ccc\\.com@',$url,$match)",
"b": "1"
},
{
"a": "!preg_match('@www\\.ddd\\.com@',$url,$match)&&!preg_match('@www\\.eee\\.com@',$url,$match)",
"b": "2"
},
{
"a": "!preg_match('@www\\.fff\\.com@',$url,$match)",
"b": "3"
}
]
EOT;
main.php
include("json.txt");
$date = json_decode($json);
foreach($date as $row){
if($row->a){// i'd like to make some judge like if(!preg_match('@www\\.fff\\.com@',$url,$match)), but now the $url make non-sence, un-worked `php variable`
echo $row->b.'<hr />';
}
}