Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Control over input

Posted on 1999-07-02
3
Medium Priority
?
151 Views
Last Modified: 2010-03-04
Hello,

I want to do the following:

$country = "netherlands, nederland, holland, nl";

if ($test = "one of the values of $country) {
      $x = 1
}

One of the values can be netherlands or nederland or holland or nl.
$test is an input out of a form.

It must be case insensitive!

So if the input $ test = "Netherlands" it also must work

greeting Michel
0
Comment
Question by:mmcw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
stam061398 earned 200 total points
ID: 1213714
$country = "netherlands, nederland, holland, nl";

$test = "Nl";


@Countries = split(", ",$country);
$Found = 0;
grep {if (uc $_ eq uc $test) {$Found = 1;}} @Countries;
print $Found,"\n";


0
 
LVL 2

Expert Comment

by:dmethvin
ID: 1213715
This is really hash territory:

my %country = map { ($_, 1) } qw(netherlands nederland holland nl);

$test = "Nl";

my $Found = $country(lc($test)) || 0;
print $Found,"\n";


0
 
LVL 2

Expert Comment

by:dmethvin
ID: 1213716
Whoops, let's try that again:

my %country = map { ($_, 1) } qw(netherlands nederland holland nl);

$test = "Nl";

my $Found = $country{lc($test)} || 0;
print $Found,"\n";


0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question