Re: [PHP] select function

2012-10-25 Thread Daniel Brown
On Thu, Oct 25, 2012 at 5:35 PM, Jeff Burcher j...@allredmetal.com wrote:
 Hi,



 I can't remember if this is the PHP list for RPG programmers or not, so
 apologize if this is the wrong one.

This is just a general PHP mailing list.  Guessing you need the other one.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] select function

2012-10-25 Thread Stuart Dallas
On 25 Oct 2012, at 22:35, Jeff Burcher j...@allredmetal.com wrote:
 I can't remember if this is the PHP list for RPG programmers or not, so
 apologize if this is the wrong one.

Not an RPG list, but your question is PHP-related more than it's RPG-related.

 Is there an equivalent command in PHP for the SELECT statement in RPG? I see
 switch, which is a little similar, but far from how it actually functions.
 
 For those not familiar with the SELECT statement here is how I envision it
 working in a PHP format similar to switch:
 
 SELECT {
 WHEN $Auth = 0:
   WHEN $A = 1:
 echo('$Aprint_list');
   WHEN $B = 1:
 echo('$Bprint_list');
   WHEN $A = 2:
 echo('$Aprint_list');
   echo('$Aprint_list');
 WHEN $B = 2:
   echo('$Bprint_list');
 echo('$Bprint_list');
   DEFAULT:
 }
 
 The syntax may be a little off, but you get the picture. No breaks are
 needed because it only performs the first match it comes to, then exits the
 SELECT statement when finished the commands under that match. Putting a WHEN
 statement with nothing to perform means exactly that, if this matches, do
 nothing, then exit the SELECT statement. I hope that makes sense. The big
 difference is you can put anything behind each WHEN statement as opposed to
 looking at only the one variable like with switch. I am thinking I just need
 to get creative with the switch or elseif commands, but thought I would ask
 the list first if they had any better suggestions.

You don't need to get creative with anything as that's exactly how switch 
works if you have a break at the end of each case. So your example would look 
like so:

switch (true) {
  case $Auth == 0:
break;
  case $A == 1:
echo('$Aprint_list');
break;
  case $B == 1:
echo('$Bprint_list');
break;
  case $A == 2:
echo('$Aprint_list');
echo('$Aprint_list');
break;
  case $B == 2:
echo('$Bprint_list');
echo('$Bprint_list');
break;
  default:
break;
}

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] select function

2012-10-25 Thread Ford, Mike
 -Original Message-
 From: Stuart Dallas [mailto:stu...@3ft9.com]
 Sent: 25 October 2012 22:48

Aw, nuts! Stuart, you just beat me to it! I was half way through writing an 
almost identical post when yours popped into my Inbox

Cheers!

Mike

-- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS,  LS1 3HE,  United Kingdom 
E: m.f...@leedsmet.ac.uk T: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php