Getting Portions of a String

Learn how to get a portion of an existing string.

The substr helper method

We can use the substr helper method to retrieve portions of an existing string. This helper defines a $start argument and an optional $length argument.

Press + to interact
<?php
/**
* Versions: Laravel 8, 9
*
* @return string
*/
public static function substr(
string $string,
int $start,
int|null $length = null
);

If the start value ...