Text Processing Functions

The substr function


The substr function extracts a substring out of a string and returns it. The function receives 3 arguments: a string value, a position on the string (counting from 0) and a length.


$a = "University";
$k = substr ($a, 3, 5);

$k is now "versi"
$a remains unchanged.
If length is omitted, everything to the end of the string is returned.

Table of Contents.
Previous | Next.