Reputation: 11297
$allAmazonMatches = Array ( [1] => B002I0HJZO [2] => B002I0HJzz [3] => B002I0HJccccccccc )
I am doing:
array_push($allAmazonMatches, array("0"=>"None of the products match"));
How ever, I am unable to add the additional array to $allAmazonMatches?
Upvotes: 0
Views: 53
Reputation: 30170
That code will work fine, so im assuming youre trying to input that text into index 0
of the array. There you should do...
$allAmazonMatches[0] = "None of the products match";
Upvotes: 1
Reputation: 59699
You don't need to use array push with just one element. Here's what you're looking to do, along with three variations in the demo:
$allAmazonMatches = array( 1 => "B002I0HJZO", 2 => "B002I0HJzz", 3 => "B002I0HJccccccccc");
$allAmazonMatches[] = "None of the products match";
var_dump( $allAmazonMatches);
Upvotes: 1
Reputation: 33678
By using array_push
you'll get:
Array(
[1] => B002I0HJZO
[2] => B002I0HJzz
[3] => B002I0HJccccccccc
[4] => Array(
[0] => None of the products match
)
)
I guess, this is not what you want but you are looking for:
Array(
[1] => B002I0HJZO
[2] => B002I0HJzz
[3] => B002I0HJccccccccc
[4] => None of the products match
)
Then you have to use:
array_merge($allAmazonMatches, array("0"=>"None of the products match"));
Upvotes: 1