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 Pointsadd yellow and black to array
i tried two different ways. what am i missing?
<?php
$colors = array("Red","Green","Blue");
//add modifications below this line
//array_push($learn,'Yellow');
//array_pop($learn,'Black');
$colors[0] = "Yellow" ;
$colors[4] = "Black" ;
Bryan Haire
2,971 Pointsthanks man! i had seen that i used the wrong syntax lol
1 Answer
Ryan LaFountain
5,449 PointsYou are welcome! Syntax errors are killer. Pasting below as the answer.
What is the objective? To move one to the front and one to the end?
To front use array_unshift($name, value);
To back use array_push($name, value);
Also note if commented out code is a previous attempt you have wrong variable name referenced.
Ryan LaFountain
5,449 PointsRyan LaFountain
5,449 PointsWhat is the objective? To move one to the front and one to the end?
To front use array_unshift($name, value);
To back use array_push($name, value);
Also note if commented out code is a previous attempt you have wrong variable name referenced.