ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的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); ```