PHP
php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
$s = "Sololearn is a great place to learn coding. Practice more to master the skills";
echo "Input string = <b>{$s}</b><br><br>";
$p_first = strpos($s, 'to');
$p_last = strrpos($s, 'to');
echo "'to' is first found at position <b>{$p_first}</b><br>";
echo "'to' is last found at position <b>{$p_last}</b><br><br>";
$p = strchr($s, 'to');
echo "String that start at first found of 'to': <b>{$p}</b><br><br>";
$p = strrchr($s, 'to');
echo "String that start at last found of 'to': <b>{$p}</b><br>";
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run