3

无论如何,我让我的东西与下面的线一起工作,但我真的无法理解。

if (preg_match_all('/[^=]*=([^;@]*)/', shell_exec("/home/technoworld/Desktop/test/b '$test'"),$matches))
                {
                        $x = (int) $matches[1][0]; //optionally cast to int
                        $y = (int) $matches[1][1];
                        $pcount= round((100*$x)/($x+$y),2);
                        $ncount= round((100*$y)/($x+$y),2);
                }

b是可执行文件,它给出的结果类似于x=10y=20

有人可以解释我里面的任何内容吗if()

4

2 回答 2

2

这:/[^=]*=([^;@]*)/将所有东西收集...=...到 $matches 数组中。

  • [^=]表示除 = 之外的任何字符
  • [^;@]指除 ; 以外的任何字符 和 @
  • ()表示将其明确收集到 $matches 中

$pcount/$ncount 从显示其比率的值中得出百分比。

于 2013-11-14T14:01:18.080 回答
2

图案细节:

[^=]*       # is a negated character class that means "all characters except ="
            # * is quantifier that means zero or more times
            # note that it seems more logical to replace it with + 
            # that means 1 or more times

=           # literal =

(           # open the capturing group 1
  [^;@]*    # all characters except ";" and "@", zero or more times
            # (same notice) 
)           # close the capturing group 1
于 2013-11-14T14:02:11.017 回答