SirChick Posted November 12, 2007 Share Posted November 12, 2007 Is this how you do a wild card in a if statement ? If ($Education1 != 'English^' && $Education2 != 'English^' && $Education3 != 'English^' && $Education4 != 'English^') or am i missing something cos its not working on my script which it should be... =/ Link to comment https://forums.phpfreaks.com/topic/77055-wildcard-in-if-statement/ Share on other sites More sharing options...
Branden Wagner Posted November 12, 2007 Share Posted November 12, 2007 What do you mean as far as Wildcar? basically you have $Education1 $Education2 $Education3 $Education4 and you want to check to see if any ALL of them not-equal??? English^ or do you want to see if ANY of them not-equal English^ if you want to check to see if ANY of them do..then use || instead of && is that what you were trying to do? or did i misunderstand Link to comment https://forums.phpfreaks.com/topic/77055-wildcard-in-if-statement/#findComment-390238 Share on other sites More sharing options...
SirChick Posted November 12, 2007 Author Share Posted November 12, 2007 no it says in the if statement what i want... to make sure all the variables do not contain English^ (English"something") Its just say i have none of them set as English something then it still echo's what ever comes next. Link to comment https://forums.phpfreaks.com/topic/77055-wildcard-in-if-statement/#findComment-390240 Share on other sites More sharing options...
SirChick Posted November 12, 2007 Author Share Posted November 12, 2007 <? If ($Education1 != 'English^' && $Education2 != 'English^' && $Education3 != 'English^' && $Education4 != 'English^'){ ?> <a href='educationprocess.php?education=English1'>English Grade 1</a> <br> <br> <? } ?> This is what i got ^ It should echo but it won't echo it. Link to comment https://forums.phpfreaks.com/topic/77055-wildcard-in-if-statement/#findComment-390243 Share on other sites More sharing options...
Branden Wagner Posted November 12, 2007 Share Posted November 12, 2007 oooh ok. ^ is not a wildcard character. (sorry i mis understood what you wanted) what you want is regex(Regular Expressions) to fix this. dont quote my regex cuz it sucks... http://us2.php.net/manual/en/function.preg-match.php if(preg_match('English[a-zA-Z0-9]+', $Education1) && ..... Link to comment https://forums.phpfreaks.com/topic/77055-wildcard-in-if-statement/#findComment-390249 Share on other sites More sharing options...
gin Posted November 13, 2007 Share Posted November 13, 2007 Firstly, you forgot to echo your text, so of course nothing is showing. Also, wouldn't it be easier to substr() what you need off the variable before you compare? <?php $x = substr ($Education1, 0, 7); if ($x <> 'English') echo 'whatever'; ?> Link to comment https://forums.phpfreaks.com/topic/77055-wildcard-in-if-statement/#findComment-390388 Share on other sites More sharing options...
SirChick Posted November 13, 2007 Author Share Posted November 13, 2007 Firstly, you forgot to echo your text, so of course nothing is showing. Also, wouldn't it be easier to substr() what you need off the variable before you compare? <?php $x = substr ($Education1, 0, 7); if ($x <> 'English') echo 'whatever'; ?> it echo's <a href='educationprocess.php?education=English1'>English Grade 1</a> as you see its withing the it's curly bracket zone {} Link to comment https://forums.phpfreaks.com/topic/77055-wildcard-in-if-statement/#findComment-390601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.