> -----Original Message----- > From: Beauford.2002 [mailto:[EMAIL PROTECTED]] > Sent: 20 December 2002 03:15 > > > Using switch would be more efficiant as it would stop once a > match is made > (if you use break), but with eleif statements each one is evaluated in > order.
Not sure that's true -- a sequence of elseifs will also stop evaluating once one of the conditions has evaluated to true. The essential difference is that a switch/case structure is a repeated test against a single value (possibly derived from an expression), whereas an if ... elseif sequence can test multiple completely disjoint conditions. > $chr = substr($a,$i,1); > switch (TRUE) { > > case $chr == "á" || $chr == "à" || $chr == "ã" || $chr == "â": > $a = str_replace(substr($a,$i,1),"a",$a); > break; > > case $chr == "é" || $chr == "è" || $chr == "ê": > $a = str_replace(substr($a,$i,1),"e",$a); > break; > > } Actually, I'm not sure that's a good example, either! I'd have thought it was better written as: switch (substr($a,$i,1)) { case "á": case "à": case "ã": case "â": $a = str_replace(substr($a,$i,1),"a",$a); break; case "é": case "è": case "ê": $a = str_replace(substr($a,$i,1),"e",$a); break; } Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php