ここの初心者、親切に別の答えの理由を説明してください。
$string = "If you’re looking for a way";
$pos = 0;
while (($pos = strpos($string,"o",$pos))!== false) {
echo $pos."<br/>";
$pos++;
}
[上記のコードの結果] 出力は次のとおりです。
4
13
14
21
$pos = 0;
$string = "If you’re looking for a way";
while ((strpos($string,"o",$pos))!== false) {
echo strpos($string,"o",$pos)."<br/>";
$pos++;
}
[上記のコードの結果] 出力は次のとおりです。
4
4
4
4
4
13
13
13
13
13
13
13
13
13
14
21
21
21
21
21
21
21