Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP PHP Arrays and Control Structures PHP Arrays Modifying Arrays

Raslan Ismail
Raslan Ismail
10,262 Points

i got this message can somebody help me "It looks like Task 1 is no longer passing."

$colors = array("Red","Green","Blue"); array_unshift($colors,"Yellow"); array_push($colors,"Black");

index.php
<?php

$colors = array("Red","Green","Blue");

array_unshift($colors,"Yellow");
array_push($colors,"Black");
array_replace($colors,1=>"Magenta",3=>"Cyan");
Juan Gonzalez
Juan Gonzalez
12,960 Points

I think it is because you are having an php error 'cause you are using the array_replace function wrong, it need to have at least 2 arrays the base one, in this case it would be the $colors array and the replace array who would be something like array( 1 => "magenta", 3=>"Cyan" ) and also, you arent asigning the value of the function to anything, so you code should look like this

<?php
$colors = array( "Red", "Green", "Blue");

array_unshift( $colors, "Yellow" );
array_push( $colors, "Black" );
$colors = array_replace( $colors, array( 1=>"Magenta",  3=>"Cyan" ) );

but I think there is also another option where you can change the values directly providing the array index like this

<?php

$colors = array("Red","Green","Blue");

//add modifications below this line
array_unshift( $colors, "Yellow" );
array_push( $colors, "Black" );
$colors[1] = "Magenta";
$colors[3] = "Cyan";

and this would help you pass this step, in the last one you just need to unset a value hope it helps!