Jump to content

WildCard in if statement


SirChick

Recommended Posts

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

 

<?
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.

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) && .....

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 {}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.