On Friday 21 January 2005 03:21, Tim Boring wrote: > On Thu, 2005-01-20 at 13:41, Jason Wong wrote: > > On Friday 21 January 2005 01:52, Tim Boring wrote: > > > > Well the biggest problem in your code right now is your incomprehensible > > (to me anyway) use of the switch construct. For a start I've no idea why > > you're using ... > > > > > switch ($line) > > > > ... when your tests do not involve $line > > > > > case ($total_counter <= 5): > > I see your point, but the other tests do involve $line. This one that > you reference I'm using for a "special need"--basically so I leave in > the initial column headings from the report, because they would match > several of the tests that would discard those lines. But as you're using switch ($line) then your tests would have to evaluate to $line for the case to be true. AFAICS your preg_match() expressions will not return $line. That's why if your test cases involve wildly different things you should use: > > I suspect what you want to be doing is something like this: > > > > switch (TRUE) { > > case ANY_EXPRESSION_THAT_EVALUATES_TO_TRUE: > > ... > > } > > Thanks for the suggestion, but I'm not sure that does what I'm looking > for. I really think the problem is with my regex, not necessarily with > the way I've constructed my switch statement. > > I say this because I have since changed the first word in each line from > something like "AKRN" to a numeric value, and everything works just as I > would expect it to. That's probably because you're relying on PHP's auto type conversion when it is evaluating your case expressions. > So it seems as if the "^" might be negating the \W+ > part of the regex. Although that shouldn't be happening because "^" > only acts as a negation when it's used inside brackets, at least > according the documentation. In any case you're (apparently (according to the subject)) trying to solve a regex problem, but you're muddying the issue by using (IMO) an incorrect switch construct. Get each of your preg_match() working properly on their own *then* stick them into the switch. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general ------------------------------------------ New Year Resolution: Ignore top posted posts -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php