substr and index function
$line="this is a test";
print substr($line, 6, 3),"\n"; # Offset starts at zero
print index($line, "test"),"\n";
print substr($line, index($line, "test")),"\n";
substr($line, 0, 0)="A, ";
print $line,"\n";
substr($line, 0, 1)="B";
print $line,"\n";
substr($line, -1, 1)="another test!";
print $line,"\n";
$string="this is another test.\n";
print rindex($string, is), "\n";
Related examples in the same category