solgun Posted March 2, 2007 Share Posted March 2, 2007 how can i make an if clause find if a variable is like "first letter"? i want to divide all shown result form a search... when the user choose one letter it shows only result starting with that letter something like if ($result LIKE 'a%') { thing happens } Thank you Quote Link to comment Share on other sites More sharing options...
AV1611 Posted March 2, 2007 Share Posted March 2, 2007 you need to do a regex but I'm lousy at them Quote Link to comment Share on other sites More sharing options...
idevlabsdotcom Posted March 2, 2007 Share Posted March 2, 2007 if(substr($result, 0, 1) == "a"){ //result starts with the letter a } or you could use regular expressions: if(eregi("^a", $result)){ //result starts with the letter a } Quote Link to comment Share on other sites More sharing options...
solgun Posted March 2, 2007 Author Share Posted March 2, 2007 Thank you very much one love Quote Link to comment Share on other sites More sharing options...
danrah Posted March 2, 2007 Share Posted March 2, 2007 you can use this regex pattern : /a*?/ $regex="/a*?/"; if(preg_match($regex,$result)){ //do something } 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.