Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 php 执行命令来运行输出字符串的游戏服务器。我需要从字符串中解析出pid,以便我可以保存它,然后在以后使用它来终止进程。
"...server daemon started with pid=6849 (parent=6848)."
所以它将返回6849。
if (preg_match('/pid=(\d+)/', $string, $matches) { $pid = $matches[1]; }