🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[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); ```