Example 1 — Get Part of a String
Give a start position and a length to cut out a piece.
<?php
$text = "Hello World";
echo substr($text, 0, 5), PHP_EOL;
echo substr($text, 6), PHP_EOL; How It Works
- Start at 0. The first character has position
0. - Take 5 characters. The first call returns
Hello. - Skip the length. The second call starts at position
6and returns the rest. - Print both. Each result is shown on its own line.

