$string = "Hello World";
$char = 'o';
$pos = 0;
while (($pos = strpos($string, $char, $pos)) !== false) {
echo "Found $char at position $pos <br>";
$pos++;
}
$string = "Hello World";
$char = 'o';
for ($i = 0; $i < strlen($string); $i++) {
if ($string[$i] == $char) {
echo "Found $char at position $i <br>";
}
}
$string = "Hello World";
$char = 'o';
$chars = str_split($string);
foreach ($chars as $key => $value) {
if ($value == $char) {
echo "Found $char at position $key <br>";
}
}