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... =/ Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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) && ..... Quote Link to comment 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'; ?> Quote Link to comment 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 {} 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.