Returns part of a string.
substr() returns part of a string, starting at a specified position. A negative start position will give an offset from the end of the string. If the optional length is specified and positive, that is the maximum number of characters that will be copied. A negative length skips that many characters at the end of the string.
<?php
$s = "Fruit: Banana";
$item = substr($s, strpos($s, ":") + 1);
$category = substr($s, 0, strpos($s, ":"));
print "Category: $category, Item: $item";
?>
Category: Fruit, Item: Banana
A string is parsed using substr() and strpos() to find a category and an item based on the position of the colon.