我有兩個文件,b.txt:用PHP爆炸第一變量是untrimmable
&first = cjnk1
&second = dcnksj2
&third = cd3
&fourth = cdln4
和a.php只會:
<?php
$data=file_get_contents("b.txt");
$rows=explode("\n", $data);
foreach($rows as $row)
{
$temp=explode(" = ",$row);
$info[ltrim($temp[0],"&")]=$temp[1];
}
echo '<pre>';
print_r($info);
echo $info["&first"];
?>
並且輸出是
Array
(
[&first] => cjnk1
[second] => dcnksj2
[third] => cd3
[fourth] => cdln4
)
最新第一個索引錯了?即使我使用它,它的不可信。
也許在'&'像不可打印的字符之前有一些東西。 – Gumbo
也許在'&'之前有一些escape-char。使用'var_dump($ temp [0]);'看看它到底是什麼。 – Leri
其字符串(9)「&first」 – filip