hansenb88 Posted January 27, 2007 Share Posted January 27, 2007 Hi, I am very new to php and was wondering if there was a wildcard operator that could be included in an if statement similar to the % operator in a mySQL query. My if statement begins like this: if ($yourfield == 'restaurant' ||... Is it possible to put in any character or command after the equal that would be like searching for 'rest%' when using mySQL? So that if the user spells a word wrong it will still execute that section of the code? Link to comment https://forums.phpfreaks.com/topic/35918-solved-wildcard-operator-in-a-php-statement/ Share on other sites More sharing options...
trq Posted January 27, 2007 Share Posted January 27, 2007 There is no wildcard, the best you could do might be.....[code]<?php if (substr($yourfield,0,4) == 'rest') { // you typed rest* }?>[/code] Link to comment https://forums.phpfreaks.com/topic/35918-solved-wildcard-operator-in-a-php-statement/#findComment-170361 Share on other sites More sharing options...
hansenb88 Posted January 27, 2007 Author Share Posted January 27, 2007 Thanks, not as efficient/easy as I had hoped, but worked perfectly. Link to comment https://forums.phpfreaks.com/topic/35918-solved-wildcard-operator-in-a-php-statement/#findComment-170364 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.