$allAmazonMatches = Array ([1] => B002I0HJZO [2] => B002I0HJzz [3] => B002I0HJccccccccc)
array_push($allAmazonMatches, array("0"=>"None of the products match"));
如何過,我無法將其它陣列添加到$ allAmazonMatches?
$allAmazonMatches = Array ([1] => B002I0HJZO [2] => B002I0HJzz [3] => B002I0HJccccccccc)
array_push($allAmazonMatches, array("0"=>"None of the products match"));
如何過,我無法將其它陣列添加到$ allAmazonMatches?
該代碼將正常工作,因此IM假設youre設法輸入文本到數組的索引0
。你應該做...
$allAmazonMatches[0] = "None of the products match";
使用array_push
你會得到:
Array(
[1] => B002I0HJZO
[2] => B002I0HJzz
[3] => B002I0HJccccccccc
[4] => Array(
[0] => None of the products match
)
)
我想,這是不是你想要什麼,但你正在尋找:
Array(
[1] => B002I0HJZO
[2] => B002I0HJzz
[3] => B002I0HJccccccccc
[4] => None of the products match
)
然後,你必須使用:
array_merge($allAmazonMatches, array("0"=>"None of the products match"));
您不需要僅使用一個元素的數組推送。這裏就是你要找做什麼,有三個變化沿demo:
$allAmazonMatches = array(1 => "B002I0HJZO", 2 => "B002I0HJzz", 3 => "B002I0HJccccccccc");
$allAmazonMatches[] = "None of the products match";
var_dump($allAmazonMatches);
你是什麼意思的「添加額外的數組」? – Arfeen