svgmx5 Posted February 16, 2011 Share Posted February 16, 2011 so i have this string that i want to search on the database My database has 3 parts city, state, country and i have a string that is say "new york city, ny, united states" and i want to be able to be able to look into the database but search those three sections so for example "New York City" i would like to search under city "NY" i want it to search under state and "United States" i want to search under country so basically how can i split the string into those three sections?? hope someone can help me with this Quote Link to comment Share on other sites More sharing options...
svgmx5 Posted February 16, 2011 Author Share Posted February 16, 2011 okay so after doing some more research i actually found a way to do it so yea thank you! Quote Link to comment Share on other sites More sharing options...
EmlynK Posted February 16, 2011 Share Posted February 16, 2011 You could use the expode() function to split the string into an array: $string = explode(",", $yourstring); $city = $string[0]; $state = $string[1]; $country = $string[2]; And then search for each one in the DB by using the $city, $state, $country variables. This could be one way of doing it. Quote Link to comment Share on other sites More sharing options...
svgmx5 Posted February 16, 2011 Author Share Posted February 16, 2011 yea thats what i ended up doing after doing much research. Thank you though Quote Link to comment Share on other sites More sharing options...
EmlynK Posted February 16, 2011 Share Posted February 16, 2011 yea thats what i ended up doing after doing much research. Thank you though If only I signed up a day earlier! But I'm glad you managed to solve it. And you're welcome. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.