php - 如何使用 fopen 和 fget 读取文件特定文本
解决方案
只需使用正则表达式:
<?php
$pattern = '/server_name::(.*)$/';
$file = '/Your/file/path/here';
preg_match($pattern, file_get_contents($file), $matches);
print_r($matches);
?>
第一个匹配项应该是服务器名称:$matches[0]
推荐阅读
- oauth-2.0 - 使用带有 Postman 的 openid-connect 获取令牌/承载
- javascript - 如何使用frontchannel处理从身份server4单点注销?
- mysql - 由于大“IN”子句,如何优化此查询,因为此 strted 挂起
- excel - 过滤数据并将数据从一张表复制到另一张表
- git - 如何进行 fetch 和 rebase?
- angular - 如何在 Angular 中销毁 Nativescript 生命周期的 applicationOn 事件
- python - 使用 pathos ProcessingPool 的地图时如何设置块大小?
- javascript - UnhandledPromiseRejectionWarning:未处理的承诺拒绝(拒绝 id:1):ReferenceError:registrationTokens 未定义
- spring - 如何使用 vaadin4spring 运行 hazelcast 会话复制?
- php - 如何在 PHP 中创建具有多个字段的数组