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
Louis Darby
5,149 PointsPHP strpos( ) - function problem.
Hi, I have made myself a shortlist feature which collects id's and stores them in a session's variable. I then use the strpos( ) function to check if the id is in the variable and change a button class from 'Add to Shortlist' to 'Added'
However, I have a place with an id of 3 and a place with an id of 13. When I add the place with an id of 13 to my shortlist and then go to my place with an id of 3 it believes it's in the shortlist and the number 3 is present in 13.
Is there a way to change alter the function so it takes the absolute value rather than just single integers?
Thanks
1 Answer
Andrew Shook
31,709 PointsWhy aren't you just checking the id against the session variable with an if statement?
thomascawthorn
22,986 Pointsthomascawthorn
22,986 PointsThis is true.. Maybe a slightly easier method would be to say (this is in note form):