[PHP] Switch case syntax
Hi Folks, In a switch, I have a load of 3 letter prefixes I'm sorting by. They are the truncated first 3 letters of alpha-numeric product codes which gives the category of the product. Some codes start with MB- for instance, and this causes a parsing error. Can I fix this without changing the fact I'm switching on a 3 letter string? Cheers -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Switch case syntax
Some codes start with MB- for instance, and this causes a parsing error. I don't see how this would cause a parse error? Can you show us an example? J -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Switch case syntax
On Tue, 21 Aug 2001 14:22, -:-Doigy-:- wrote: Hi Folks, In a switch, I have a load of 3 letter prefixes I'm sorting by. They are the truncated first 3 letters of alpha-numeric product codes which gives the category of the product. Some codes start with MB- for instance, and this causes a parsing error. Can I fix this without changing the fact I'm switching on a 3 letter string? Cheers You are sticking those values in quotes? Frinstance switch($variable) { case 'IBM': break; case 'DEC': break; case 'MB-': break; } -- David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA If I knew what I was doing...I'd be dangerous... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Switch case syntax
No, they weren't in quotes strangely. Adding quotes removes parsing error. Thanks David -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]