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 Link to comment https://forums.phpfreaks.com/topic/227856-how-break-a-string-into-sections/ 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! Link to comment https://forums.phpfreaks.com/topic/227856-how-break-a-string-into-sections/#findComment-1174934 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. Link to comment https://forums.phpfreaks.com/topic/227856-how-break-a-string-into-sections/#findComment-1174935 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 Link to comment https://forums.phpfreaks.com/topic/227856-how-break-a-string-into-sections/#findComment-1174936 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. Link to comment https://forums.phpfreaks.com/topic/227856-how-break-a-string-into-sections/#findComment-1174938 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.