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 trialBryan Haire
2,971 Pointsphp array color change
change the colors in array
<?php
$colors = array("Red","Green","Blue");
//add modifications below this line
array_unshift($colors,'Yellow');
array_push($colors,'Black');
unset($colors[1],$colors[3]);
$colors[1] = "Blue";
$colors[3] = "Cyan";
1 Answer
Daniel Marin
8,021 PointsThis is how the final code should look:
<?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";
unset($colors[2]);
Also don't forget to run
var_dump($colors)
trough the preview so you can see how the array looks
Antonio De Rose
20,885 PointsAntonio De Rose
20,885 Pointshope you are after the last challenge, where to remove the element green, as I see the first and the second challenge, are correct. do you want to do some search on unset with using the index to remove