Solved

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

Posted on 2008-06-11
7
219 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
[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
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

695 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