企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
[TOC] ## 示例 items.txt ``` coins 5 pens 6 chairs 12 books 20 ``` ``` $fh = fopen("a.txt", "r"); if ($fh === false) { exit("Cannot read file\n"); } while ($data = fscanf($fh, "%s %d")) { list($item, $quantity) = $data; echo "$item: $quantity\n"; //coins: 5 //pens: 6 //chairs: 12 //books: 20 } fclose($fh); ```