我需要使用PHP打印出包含给定子字符串“ Happy”的所有字符串。
$t包含所有输入数据。我尝试这样做,但是无法达到预期的输出。
$i = 1;
while ($t = dbNext($r)) {
$temp = strtolower($t[0]);
if(strpos($temp, 'happy')){
echo "$i - $t[0]";
echo "\n";
$i++;
}
}
输入:
1. Happy Gilmore
2. The Fast and the Furious
3. Happy, Texas
4. The Karate Kid
5. The Pursuit of Happyness
6. Avengers: End Game
7. Happy Feet
8. Another Happy Day
预期产量:
1. Happy Gilmore
2. Happy, Texas
3. The Pursuit of Happyness
4. Happy Feet
5. Another Happy Day
我得到的输出:
1. The Pursuit of Happyness
2. Another Happy Day
三国纷争
哔哔one