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 trialA X
12,842 PointsI'm Not Understanding what Unset is/does Fully.
I just watched Alena's video where she intro's Unset, but I'm not understanding fully what the point of unset is. It removes items from an array, but is the removal permanent? Is this the closest we get in PHP to a delete function in an array vs. array_shift/pop?
5 Answers
Amy Dollar
2,562 PointsYes he probably did Alexander, but these questions are also useful for others who are new to the lessons ;)
saif ahmad
6,352 Pointsi am also working with php Alex . I would suggest that if you don't get any concept watch the video as much as possible. After you got it don't stop go to workspaces or whichever code editor and try using that concept. Application of concepts is most important in web dev. Hope this helps! Bye bye -saif ahmad
Randall Wilson
528 PointsI think she was saying that you can use unset to take it out of an array and if you need to put it somewhere else. All unset does is it takes the value AND its key out of the current array to be placed somewhere else.
Alexander Davison
65,469 PointsUm... You are replying to a question made 1 month ago lol
I think Nekilof already found out the answer to her question.
Sam Gord
14,084 Pointsunless gives you the ability to remove elements from an array by their index number, its pretty easy .
$learn = array('html','css','javascript'); html's index number ( key ) --> 0 css's index number ( key ) --> 1 javascript's index number ( key ) --> 2
unset($learn[1],$learn[2]);
here i removed 'css' and 'javascript' from $learn array using unset .
Alexander Davison
65,469 PointsYou should try experimenting that in Workspaces :)
If you want to create a Workspace you can create (up to 100!) Workspaces here.
Coding is very important, maybe even (slightly) more important than watching the videos!
Also researching can help a ton. You can always search up your question on Google or any other search engine you enjoy using
I hope this helps. ~Alex