<?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";
offset and length, negatives count from the end