<?php declare(strict_types=1);
function pnl(string $string){
print($string . PHP_EOL . PHP_EOL);
}
$paragraph = <<<PARA
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of
type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into
electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset
sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker
including versions of Lorem Ipsum.
PARA;
$a = substr($paragraph,15,12);
pnl('Sub String:');
pnl($a);
$last20 = substr($paragraph, -20, 20);
$b = strpos($paragraph, 'simply');
pnl('Starting postion of first simply: ' . $b);
$last = strrpos($paragraph, 'Lorem');
pnl('Starting postion of last Lorem: ' . $last);
$c = stripos($paragraph,'SImpLY');
pnl('Starting postion of first SImpLY (case insensative): ' . $c);
$d = strstr($paragraph, 'simply');
pnl('String String:');
pnl($d);
$e = str_replace('Lorem Ipsum', 'Heyyy', $paragraph);
pnl('Replacing Strings:');
pnl($e);
$f = str_ireplace('HEYYY', 'Oh', $e);
pnl('Replacing Strings Case Insensitive:');
pnl($f);
$g = strlen($paragraph);
pnl('Length of the whole paragraph: ' . $g);
$startPos = stripos($paragraph,'SpeCimen');
$len = $g - $startPos;
$mystrstr = substr($paragraph, $startPos, $len);
pnl('My Own strstr:');
pnl($mystrstr);
$lenLast = $g - $last;
$llo = substr($paragraph, $last, $lenLast);
$lloo = substr($paragraph, 0 - $lenLast, $lenLast);
pnl('Last Lorem Onwards:');
pnl($llo);
pnl('or:');
pnl($lloo);
$firstSpaceInLlo = strpos($llo, ' ');
$justLastLorem = substr($llo, 0, $firstSpaceInLlo);
pnl('Just the last lorem (diff way?):');
pnl($justLastLorem);
$toChange = 'it';
$lastIt = strripos($paragraph, $toChange);
$changeTo = substr($paragraph, $lastIt, strlen($toChange));
$changed = str_ireplace($toChange, $changeTo, $paragraph);
pnl('Change all \'it\' to match the last \'it\':');
pnl($changed);
$cap = str_replace(['a','e','i','o','u'], ['A','E','I','O','U'], $paragraph);
pnl('Capitalise vowels:');
pnl($cap);