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 trialAdam Smallman
4,182 PointsNon mysql search bar?
Is it possible to make a php search bar with out using mysql ? Maybe get php to look and search through an array ?
Thanks
Adam
2 Answers
Craig Chivers
3,820 PointsYou can search an array using the command array_search( value, array, strict ); array_search takes 3 parameters, value, array, strict;
<?php $a=array("a"=>"red","b"=>"green","c"=>"blue"); echo array_search("red",$a); ?>
Adam Smallman
4,182 Pointsyer sort of. Just like the search bar on this site (TreeHouse.com) but with out using a database.
Adam Smallman
4,182 PointsAdam Smallman
4,182 PointsYes that works. but what I am looking to do is to make an html form that a user can type in something say the letter "a" for example then when the user submits, php searches through an array for something to mach the letter with.
Craig Chivers
3,820 PointsCraig Chivers
3,820 PointsSo are you trying to search 'a' and have everything in the array with an 'a' show up?