我有一个文本文件作为 list.txt。list.txt 的内容如下:
user1:site1.com
user2:site2.com
user3:site3.com
user4:site4.com
我使用了以下代码:
$a=file('list.txt');
foreach ($a as $final) {
list($user, $site) = explode(":", $a);
echo ($user." is the user of ".$site);
}
我希望输出显示:
user1 is the user of site1.com
user2 is the user of site2.com
user3 is the user of site3.com
user4 is the user of site4.com
任何人都可以解决我的问题。我是 php 的初学者。我在数组函数中遇到问题。