Solved

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

Posted on 2008-06-11
7
214 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

760 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

20 Experts available now in Live!

Get 1:1 Help Now