Solved

elseif ($_SESSION['country'] == 'br') need multiple values where br is

Posted on 2008-06-11
7
215 Views
Last Modified: 2012-05-05
Is it possible to have multiple values where I have my "br"?

elseif ($_SESSION['country'] == 'br'){

tried: elseif ($_SESSION['country'] == 'br,mx,nl')

But doesn't work.  Thank you
0
Comment
Question by:vrmetro
  • 5
  • 2
7 Comments
 
LVL 16

Expert Comment

by:DrNikon224
ID: 21764727
Try:

elseif(in_array($_SESSION['country'],array('br','mx','nl'))
0
 

Author Comment

by:vrmetro
ID: 21764907
tried it and did not work, thanks though.
0
 

Author Comment

by:vrmetro
ID: 21764936
a little more clarification,

these are outputing information submitted on a previous form with the values stored in the session; see code below, I would like to not have 3 different elseif echos and use the same elseif for de, fr, and nl which are the values of three different countries submitted on the previous form, only one will be stored in the session.  
			elseif ($_SESSION['country'] == 'de'){

			 echo

            	"You'll need a phone with GPS on a GSM Network<br />

				<div id=\"plans\">

			 <div class=\"plan_left\">

				<p class=\"notice\">

     				<input type=\"checkbox\" name=\"plan\" id=\"plan\" value=\"12.95_eu\" /><img src=\"images/spacer.gif\" width=\"15\" height=\"1\">

					Unlimited &euro;12.95/month<br />

					<img src=\"images/spacer.gif\" width=\"1\" height=\"10\"><br />

					<span class=\"sm-text\">Use as much as you'd like - This plan includes<br />

					Location History: See current location and history<br />

					Speeding Alerts: Customize</span><br />

   				</p>

			 </div>

			 <div class=\"plan_right\">

			 	<img src=\"images/blackberry_w_target.jpg\" width=\"111\" border=\"0\" />

			 </div>

        	</div> 

			<br />";

			} //end div

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Accepted Solution

by:
DrNikon224 earned 250 total points
ID: 21765269
Make sure I understand correctly - $_SESSION['country'] will be any ONE of de,fr or nl? And you want to see if $_SESSION['country'] is any one of those values? If this is the case, then in_array() is definitely what you need, we just need to figure out why it's not doing what you expect in your usage.

Are you able to post the whole script here?
0
 

Author Comment

by:vrmetro
ID: 21771112
This line works:
elseif ($_SESSION['country'] == 'DE'||$_SESSION['country'] == 'NL'){
echo //somecode
}

This one does too, but still only for DE and NL, FR does not work for some reason:
elseif ($_SESSION['country'] == 'DE'||$_SESSION['country'] == 'NL'||$_SESSION['country'] == 'FR'){
echo //somecode
}

                  
0
 

Author Comment

by:vrmetro
ID: 21771143
Scratch that, it does work.  Was access in wrong test space.  Thank you for your help though, if there is a cleaner way to do this using in_array I'd very much like to know how.  If not, I'll wait a few hours and assign points for your help.  thank you!
0
 

Author Closing Comment

by:vrmetro
ID: 31466391
I'd like to find out how to use the in_array command to accomplish the same goal if possible.  thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now