gpt4 book ai didi

php - 了解 preg_match 公式

转载 作者:可可西里 更新时间:2023-11-01 01:02:34 25 4
gpt4 key购买 nike

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

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()

最佳答案

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

  • [^=] 表示除了 =
  • 以外的任意字符
  • [^;@] 表示除 ; 之外的任意字符和@
  • () 表示将其显式收集到 $matches

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

关于php - 了解 preg_match 公式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19979580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com