0
继承人我的代码帮助用PHP数组
$cont = file_get_contents("users.txt");
$lines = explode("\n",$cont, true);
if(in_array('$name', $line)) {
echo "Error user $name in database";
exit;}
我有那么一个文本文件与用户名的文件都被转换为一个数组($线) 我需要它来搜索阵列,看看
$cont = file_get_contents("users.txt");
$lines = explode("\n", $cont, true);
if(in_array($name, $lines)) {
echo "Error user $name in database";
exit;
}
:在文本文件中
不确定在代码示例中设置$ name变量的位置,但不应该在其中包含单个$引号。 – dkinzer 2011-04-18 04:09:20
现在你总是使用字符串'$ name'而不是一个变量?你的条件应该看起来像“if(in_array($ name,$ lines))” – Nemoden 2011-04-18 04:10:26