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 Link to comment https://forums.phpfreaks.com/topic/40898-help-with-if-statment/ 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 Link to comment https://forums.phpfreaks.com/topic/40898-help-with-if-statment/#findComment-198084 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 } Link to comment https://forums.phpfreaks.com/topic/40898-help-with-if-statment/#findComment-198087 Share on other sites More sharing options...
solgun Posted March 2, 2007 Author Share Posted March 2, 2007 Thank you very much one love Link to comment https://forums.phpfreaks.com/topic/40898-help-with-if-statment/#findComment-198088 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 } Link to comment https://forums.phpfreaks.com/topic/40898-help-with-if-statment/#findComment-198090 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.