SPraus Posted March 30, 2009 Share Posted March 30, 2009 Hello Everyone, I am looking for some help on a specialised searching function. Here is what I have. Bob;Joe;Jim;Another Example Name; This is contained in an SQL database, each of these are tags for a product such as things made for computers only or just made for cars. I would like to search for a ; and save only what is before it. Here is kinda what I think. the {} are just for more explanation $char = ; SearchStr($string,$char) now copy the stuff before the ; for the next copy from ; number 2 to ; number 1. and so on and so forth. Please help if you have any ideas. SPraus PS if you dont understand please reply and I will try to explain more. I know i didnt explain it too well. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/151767-solved-solved-specialized-searching-search-for-parts-of-strings/ Share on other sites More sharing options...
ober Posted March 30, 2009 Share Posted March 30, 2009 http://us.php.net/explode $str = "Bob;Joe;Jim;Another Example Name;"; $myarray = explode(';', $str); // $myarray is now an array of the various pieces and you can search it using array functions. Quote Link to comment https://forums.phpfreaks.com/topic/151767-solved-solved-specialized-searching-search-for-parts-of-strings/#findComment-796919 Share on other sites More sharing options...
lonewolf217 Posted March 30, 2009 Share Posted March 30, 2009 i think what you want is Explode() $names = "John;Sally;Susan;Chris"; $nameArray = explode(";",$names); now what you have is an array of names where you can go through each one individually $nameArray[0] = "John" $nameArray[1] = "Sally" ...etc if this isn't what you want you need to explain more about exactly what you are searching for and what you want to do with the data Quote Link to comment https://forums.phpfreaks.com/topic/151767-solved-solved-specialized-searching-search-for-parts-of-strings/#findComment-796922 Share on other sites More sharing options...
SPraus Posted March 30, 2009 Author Share Posted March 30, 2009 Thanks guys, this solved it. PS thanks for being so ridiculously fast lol. usually id wait a week for someone to respond so thank you very much!!!! Quote Link to comment https://forums.phpfreaks.com/topic/151767-solved-solved-specialized-searching-search-for-parts-of-strings/#findComment-796930 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.