Php 不生成爆炸数组
基本上,我试图让我的PHP代码搜索通过一个txt文件,其中有Surburbs和邮政编码(3000,墨尔本)等。用户输入一个郊区和相应的邮政编码打印出来 我认为几乎所有的方式,但没有打印出来。不太清楚为什么。问了我的一些网络开发朋友,但他们没有帮助哈哈。 任何帮助都将不胜感激。。 谢谢:)Php 不生成爆炸数组,php,Php,基本上,我试图让我的PHP代码搜索通过一个txt文件,其中有Surburbs和邮政编码(3000,墨尔本)等。用户输入一个郊区和相应的邮政编码打印出来 我认为几乎所有的方式,但没有打印出来。不太清楚为什么。问了我的一些网络开发朋友,但他们没有帮助哈哈。 任何帮助都将不胜感激。。 谢谢:) 在下面的文本框中输入郊区名称,然后单击“搜索”按钮查看 结果呢 郊区: 打印($postcodes)并确保它不是空的。爆炸时你也不需要位置。你会爆炸(“除味剂”,arrayname)。“分解”将其转换为字符串
在下面的文本框中输入郊区名称,然后单击“搜索”按钮查看
结果呢
郊区:
打印($postcodes)并确保它不是空的。爆炸时你也不需要位置。你会爆炸(“除味剂”,arrayname)。“分解”将其转换为字符串,并由除味器分隔。@clearshot66如果将其向后放置,则“分解”将字符串转换为数组。。。内爆将数组变成字符串我的错误:)已经有一段时间了
<html>
<body>
<p>INPUT AN SUBURB NAME IN BELOW TEXT BOX AND CLICK 'SEARCH' BUTTON TO SEE
THE RESULT.</p>
<form>
Suburb:<input type="text" name="suburb"/><input type="submit"
value="search"/>
</form>
<?php
if(isset($_GET['suburb']))
{
//load email from file
$file = "postcode.txt";
if(!file_exists($file ))
{
echo "No file found!";
}
else
{
$postcodes=file($file);
for($i=0;$i<count($postcodes);$i++)
{
$postcodes[$i]=str_replace("\n","",$postcodes[$i]);
$curPostcode = explode(",", $postcodes[$i]);
if(isset($array_postcode))
{
$array_postcode+=array($curPostcode[1]=>$curPostcode[0]);
}
else
{
$array_postcode=array($curPostcode[1]=>$curPostcode[0]);
}
}
if(isset($array_postcode))
{
echo "nothing"
;}
else {
//print_r($array_postcode);
echo "The postcode of ".$_GET['suburb']." is : "
.$array_postcode['suburb'];
}}
}
?>
</body>
</html>