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 trialJosh Coast
5,112 PointsIf I add a movie called "Apple" to the data.php it ends up at the bottom of the list instead of the front? Why?
When I add a movie to data.php with the title "Apple" and a key of 204, it ends up at the bottom of the list instead of first? When I comment out the $sort = ltrim($sort, "A ");
and $sort = ltrim($sort, "An ");
lines, Apple ends up at the front again. I didn't forget the space after the A string. I'm not sure what's going on here. Any ideas?
2 Answers
Josh Coast
5,112 PointsAh, thanks Jacques Olivier, I thought that it had to match the full string, including the space, to be removed.
Jacques Olivier
9,864 PointsYou are welcome. Check out the PHP docs, they can be difficult to read at times but once you get use to it, it becomes much easier to find a reference there.
Jacques Olivier
9,864 PointsJacques Olivier
9,864 PointsJust remember that The ltrim() function removes whitespace or other predefined characters from the left side of a string. So it removes the A in both cases