PHP Cookbook: Extracting Substrings

Problem You want to extract part of a string, starting at a particular place in the string. For example, you want the first eight characters of a username entered into a form. Solution Use substr( ) to select your substring, as in Example 1-9. Example 1-9. Extracting a substring with substr( ) Discussion