kannu Posted January 28, 2008 Share Posted January 28, 2008 hello, after you read the question you would realize i am a true newbie in php, but what can i do now. i have to start somewhere. my questions is that i am trying to create a simple "if then else" statement where i am trying to see if a string contains a set of letters. but i cannot find any function which can let me search if a string has those letters and continue in the if else statement. for example :- $wert = "catid52product34show" if($wert == "product34") { do this } else if($wert == "product35") { do that} how can i search for "product34" within the variable $wert. and then proceed according on if then else statement if someone can please help me out, i would really appreciate the same thanks Quote Link to comment https://forums.phpfreaks.com/topic/88124-solved-call-me-dumb-but-can-someone-please-help-me-out-with-this/ Share on other sites More sharing options...
iwannabeleet Posted January 28, 2008 Share Posted January 28, 2008 I think SUBSTR might do what you're looking for? Quote Link to comment https://forums.phpfreaks.com/topic/88124-solved-call-me-dumb-but-can-someone-please-help-me-out-with-this/#findComment-450883 Share on other sites More sharing options...
iwannabeleet Posted January 28, 2008 Share Posted January 28, 2008 oops I think i misunderstood, maybe preg_match() or strstr()? Quote Link to comment https://forums.phpfreaks.com/topic/88124-solved-call-me-dumb-but-can-someone-please-help-me-out-with-this/#findComment-450890 Share on other sites More sharing options...
KrisNz Posted January 28, 2008 Share Posted January 28, 2008 if you just want to see if one string is contained in another string, strpos() is the fastest way. strpos manual page Quote Link to comment https://forums.phpfreaks.com/topic/88124-solved-call-me-dumb-but-can-someone-please-help-me-out-with-this/#findComment-450900 Share on other sites More sharing options...
awpti Posted January 28, 2008 Share Posted January 28, 2008 This just looks like really bad design. Stop now and rethink your processes. This will only lead to FAIL. Quote Link to comment https://forums.phpfreaks.com/topic/88124-solved-call-me-dumb-but-can-someone-please-help-me-out-with-this/#findComment-450918 Share on other sites More sharing options...
kankaro Posted January 28, 2008 Share Posted January 28, 2008 hello i'm a newbe also in php, but when i look at your code it' something hard to work on it. If yuo want your code to work smoohtly make a database on it. it will surely find what you want. insert those words in the database. Quote Link to comment https://forums.phpfreaks.com/topic/88124-solved-call-me-dumb-but-can-someone-please-help-me-out-with-this/#findComment-450922 Share on other sites More sharing options...
kannu Posted January 28, 2008 Author Share Posted January 28, 2008 hey guys, thanks to all of you for your reply and responses. specially to "iwannabeleet" i used the preg_match that she recommended and it works beautifully. i have a database installed and it works. i just need to make a small change and i could not figure out, so i wanted to use the above function. thanks again to all of you for taking time to reply to my query. i really appreciate the same. Quote Link to comment https://forums.phpfreaks.com/topic/88124-solved-call-me-dumb-but-can-someone-please-help-me-out-with-this/#findComment-450933 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.