Re: [PHP] Re: Switch - Case Statement Questions

2012-11-19 Thread Andrew Ballard
On Sat, Nov 17, 2012 at 4:13 PM, Sebastian Krebs wrote: > 2012/11/17 Andrew Ballard > >> On Nov 16, 2012 10:24 PM, "tamouse mailing lists" >> wrote: >> > >> > On Fri, Nov 16, 2012 at 12:41 PM, Sebastian Krebs >> wrote: >> > > Beside this it can be rewritten as >> > > >> > > switch ((int) (($cou

Re: [PHP] Re: Switch - Case Statement Questions

2012-11-19 Thread Sebastian Krebs
2012/11/19 Tim Streater > On 18 Nov 2012 at 14:44, Jim Giner wrote: > > > 2. Using Switch {ALWAYS FIRST CASE!!!} > > > > //$boxes = 1; > > //switch ($count) { > > //case ($count > 14): > > //$boxes = 3; > > //

Re: [PHP] Re: Switch - Case Statement Questions

2012-11-19 Thread Stuart Dallas
On 19 Nov 2012, at 19:35, Tim Streater wrote: > On 18 Nov 2012 at 14:44, Jim Giner wrote: > >> 2. Using Switch {ALWAYS FIRST CASE!!!} >> >> //$boxes = 1; >> //switch ($count) { >> //case ($count > 14): >> //$boxes = 3; >>

[PHP] Re: Switch - Case Statement Questions

2012-11-19 Thread Tim Streater
On 18 Nov 2012 at 14:44, Jim Giner wrote: > 2. Using Switch {ALWAYS FIRST CASE!!!} > > //$boxes = 1; > //switch ($count) { > //case ($count > 14): > //$boxes = 3; > //break; > //case ($count >

Re: [PHP] Re: Switch - Case Statement Questions

2012-11-19 Thread Jim Giner
On 11/16/2012 8:33 PM, Iñigo Medina wrote: On Fri, 16 Nov 2012, Jim Giner wrote: On 11/16/2012 12:38 PM, Tim Streater wrote: On 16 Nov 2012 at 12:10, Omar Muhsin wrote: Hello, I was just wondering after writting the code in version 2 here below, it turns out in testing that it actually PH

Re: [PHP] Re: Switch - Case Statement Questions

2012-11-17 Thread tamouse mailing lists
On Sat, Nov 17, 2012 at 2:59 PM, Sebastian Krebs wrote: > (Beside: Was "the principle of least surprise" not a ruby-thing? ;)) No, but the Ruby (and Rails) world takes concepts like this and really runs with them. Principle of Least Astonishment has been around for quite some time, with examples

Re: [PHP] Re: Switch - Case Statement Questions

2012-11-17 Thread tamouse mailing lists
On Sat, Nov 17, 2012 at 3:13 PM, Sebastian Krebs wrote: > 2012/11/17 Andrew Ballard > >> On Nov 16, 2012 10:24 PM, "tamouse mailing lists" >> wrote: >> > Just a tad obscure for someone coming along >> > later >> >> Without knowing the intent of the code, it could be a headache to maintain. >> >

Re: [PHP] Re: Switch - Case Statement Questions

2012-11-17 Thread Sebastian Krebs
2012/11/17 Andrew Ballard > On Nov 16, 2012 10:24 PM, "tamouse mailing lists" > wrote: > > > > On Fri, Nov 16, 2012 at 12:41 PM, Sebastian Krebs > wrote: > > > Beside this it can be rewritten as > > > > > > switch ((int) (($count-1) / 7) { > > > case 0: // 1-7 > > > case 1: // 8 - 14 > > >

Re: [PHP] Re: Switch - Case Statement Questions

2012-11-17 Thread Sebastian Krebs
2012/11/17 Tim Streater > On 17 Nov 2012 at 01:33, Iñigo Medina wrote: > > > On Fri, 16 Nov 2012, Jim Giner wrote: > > >> Maybe I'm way out of touch, but when I look at php.net for the syntax > of the > >> switch statement I see: > >> switch($var){ > >> case (value): > >> (do s

Re: [PHP] Re: Switch - Case Statement Questions

2012-11-17 Thread Andrew Ballard
On Nov 16, 2012 10:24 PM, "tamouse mailing lists" wrote: > > On Fri, Nov 16, 2012 at 12:41 PM, Sebastian Krebs wrote: > > Beside this it can be rewritten as > > > > switch ((int) (($count-1) / 7) { > > case 0: // 1-7 > > case 1: // 8 - 14 > > default: // above 15 > > } > > Nice code refacto

Re: [PHP] Re: Switch - Case Statement Questions

2012-11-17 Thread Stuart Dallas
On 17 Nov 2012, at 10:53, Tim Streater wrote: > On 17 Nov 2012 at 01:33, Iñigo Medina wrote: > >> On Fri, 16 Nov 2012, Jim Giner wrote: > >>> Maybe I'm way out of touch, but when I look at php.net for the syntax of the >>> switch statement I see: >>> switch($var){ >>> case (value): >>>

[PHP] Re: Switch - Case Statement Questions

2012-11-17 Thread Tim Streater
On 17 Nov 2012 at 01:33, Iñigo Medina wrote: > On Fri, 16 Nov 2012, Jim Giner wrote: >> Maybe I'm way out of touch, but when I look at php.net for the syntax of the >> switch statement I see: >> switch($var){ >> case (value): >> (do something) >> case (other value): >>

Re: [PHP] Re: Switch - Case Statement Questions

2012-11-16 Thread tamouse mailing lists
On Fri, Nov 16, 2012 at 12:41 PM, Sebastian Krebs wrote: > Beside this it can be rewritten as > > switch ((int) (($count-1) / 7) { > case 0: // 1-7 > case 1: // 8 - 14 > default: // above 15 > } Nice code refactoring :) Just a tad obscure for someone coming along later, perhaps. -- PHP Ge

Re: [PHP] Re: Switch - Case Statement Questions

2012-11-16 Thread Iñigo Medina
On Fri, 16 Nov 2012, Jim Giner wrote: On 11/16/2012 12:38 PM, Tim Streater wrote: On 16 Nov 2012 at 12:10, Omar Muhsin wrote: Hello, I was just wondering after writting the code in version 2 here below, it turns out in testing that it actually PHP is not validating the expressions instea

[PHP] Re: Switch - Case Statement Questions

2012-11-16 Thread Jim Giner
On 11/16/2012 12:38 PM, Tim Streater wrote: On 16 Nov 2012 at 12:10, Omar Muhsin wrote: Hello, I was just wondering after writting the code in version 2 here below, it turns out in testing that it actually PHP is not validating the expressions instead always I get the first case. 1.Using nes

Re: [PHP] Re: Switch - Case Statement Questions

2012-11-16 Thread Sebastian Krebs
2012/11/16 Tim Streater > On 16 Nov 2012 at 12:10, Omar Muhsin wrote: > > > Hello, > > > > I was just wondering after writting the code in version 2 here below, it > turns > > out in testing that it actually PHP is not validating the expressions > instead > > always I get the first case. > > > >

[PHP] Re: Switch - Case Statement Questions

2012-11-16 Thread Tim Streater
On 16 Nov 2012 at 12:10, Omar Muhsin wrote: > Hello, > > I was just wondering after writting the code in version 2 here below, it turns > out in testing that it actually PHP is not validating the expressions instead > always I get the first case. > > 1.Using nested if statement {THE INTENDED BEH