Return "world" from the string:
echo substr("Hello world",6);
Using the start parameter with different positive and negative numbers:
// Positive numbers:
echo substr("Hello world",10)."<br>"; //d
echo substr("Hello world",1)."<br>"; //ello world
echo substr("Hello world",3)."<br>"; //lo world
echo substr("Hello world",7)."<br>"; //orld
echo "<br>";
// Negative numbers:
echo substr("Hello world",-1)."<br>"; //d
echo substr("Hello world",-10)."<br>"; //ello world
echo substr("Hello world",-8)."<br>"; //lo world
echo substr("Hello world",-4)."<br>"; //orld
Using the start and length parameters with different positive and negative numbers:
// Positive numbers:
echo substr("Hello world",0,10)."<br>"; //Hello worl
echo substr("Hello world",1,8)."<br>"; //ello wor
echo substr("Hello world",0,5)."<br>"; //Hello
echo substr("Hello world",6,6)."<br>"; //world
echo "<br>";
// Negative numbers:
echo substr("Hello world",0,-1)."<br>"; //Hello worl
echo substr("Hello world",-10,-2)."<br>"; //ello wor
echo substr("Hello world",0,-6)."<br>"; //Hello