Solved

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

Posted on 2008-06-11
7
216 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
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 
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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
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…
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…
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…

770 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