|
Posted by Michael on 02/02/05 17:34
I'm trying to use stripos as a faster and less resource-intensive
alternative to preg_match with the i flag, but I'm getting some strange
behavior.
Here's a test script that demonstrates the problem:
---
<?php
$days = array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun");
foreach ($days as $d) {
echo "Checking day: $d";
if (stripos($d, 'T') === 0) {
echo "Day is Tuesday or Thursday";
} else {
echo "Day is MWFSS";
}
}
?>
---
When I run this as-is, it prints "Checking day: Mon" and stops. When I
change stripos to strpos, it runs all the way through doing what it's
supposed to. It's as if stripos calls 'die' somehow and strpos doesn't.
AFAIK, stripos should behave exactly like strpos except
case-insensitively. So in the function above, it should make absolutely
no difference which one I use.
Any thoughts?
Thanks!
PS: Ignore the fact I'm using days above, what I'm really doing has
nothing to do with date handling. That was just a convenient example to
demonstrate the problem.
[Back to original message]
|