Strings In Depth16 / 18
Up next

Substrings with substr

<?php
declare(strict_types=1);
$s = "hello world";
// substr(string, offset, length)
echo substr($s, 0, 5), "\n";
// a negative offset starts from the end
echo substr($s, -5), "\n";
What you're solving

offset and length, negatives count from the end