PHP Developer’s Dictionary IT-SC book 560 The imagettfbbox() function, which was added in PHP 3.0.1, calculates, based on the size , angle , and font , and returns the bounding box in pixels for a TrueType text . The font parameter can either be a filename or a URL. The contents of the array returned can be seen in Table 11.23. Table 11.23. Contents of the Returned Array Indexed Array Position Description 0 Lower-left corner, x-coordinate 1 Lower-left corner, y-coordinate 2 Lower-right corner, x-coordinate 3 Lower-right corner, y-coordinate 4 Upper-right corner, x-coordinate 5 Upper-right corner, y-coordinate 6 Upper-left corner, x-coordinate 7 Upper-left corner, y-coordinate imagettftext() Syntax array imagettftext(int image, int size, int angle, int x, int y, int color, string font, string text) Description The imagettftext() function writes, based on the size , angle , and font , a TrueType text to image . The font parameter can either be a filename or a URL. It starts at the x and y position. imagetypes() Syntax int imagetypes(); Description The imagetypes() function, which was added in PHP 4.0.2, returns the image formats supported by your build of PHP. The following items represent what can be returned: • IMG_GIF PHP Developer’s Dictionary IT-SC book 561 • IMG_JPG • IMG_PNG • IMG_WBMP Regular Expressions Having the ability to effectively parse text for characters and phrases of various formats is an extremely powerful thing. The modules discussed in this section describe the regular expression functions available in PHP. The discussion is broken into "Native PHP" and "Perl Semantics" sections. Native PHP These sets of functions are for performing regular expression pattern matching in PHP. Unlike the items listed in the "Perl Semantics" section of this chapter, these functions represent semantics and syntax that are native to PHP. ereg() Syntax int ereg(string pattern, mixed string [, array matches]) Description The ereg() function searches string for any items that match the pattern . If the optional matches array variable is passed, the results are stored in that array. Otherwise, the function returns 1 if a match was found, and 0 if not. The only difference between this and the eregi() function is that this function does not ignore alphabetic case. ereg_replace() Syntax string ereg_replace(string pattern, mixed replacement, mixed string) Description The ereg_replace() function searches string for pattern and replaces it with replacement . If successful, the modified string is returned. PHP Developer’s Dictionary IT-SC book 562 eregi() Syntax int eregi(string pattern , string string [, array regs ]) Description The eregi() function searches string for any items that match the pattern . If the optional matches array variable is passed, the results are stored in that array. Otherwise, it returns 1 if a match was found, and 0 if not. The only difference between this and the ereg() function is that this function ignores alphabetic case. eregi_replace() Syntax string eregi_replace(string pattern, string replacement, string string) Description The eregi_replace() function searches string for pattern and replaces it with replacement . If successful, the modified string is returned. The only difference between this and the eregi_replace() function is that this function ignores alphabetic case. split() Syntax array split(string pattern, mixed string [, int limit]) Description The split() function searches string and splits it into individual elements, each stored in the returned array, based on the pattern . You can limit the number of items stored in the array by using the optional limit parameter. The only difference between this and the spliti() function is that this function does not ignore alphabetic case. spliti() PHP Developer’s Dictionary IT-SC book 563 Syntax array split(string pattern, mixed string [, int limit]) Description The spliti() function, which was added in PHP 4.0.1, searches string and splits it into individual elements, each stored in the returned array, based on the pattern . You can limit the number of items stored in the array using the optional limit parameter. The only difference between this and the split() function is that this function ignores alphabetic case. sql_regcase() Syntax string sql_regcase(string string) Description The sql_regcase() function takes a string and returns a new string that contains the uppercase and lowercase equivalents of the characters in the string , each contained in its own set of brackets. echo sql_regcase ("Hello World"); // [Hh][Ee][Ll][Ll][][Ww][Oo][Rr][Ll][Dd] Perl Semantics These sets of functions are for performing regular expression pattern matching. However, their syntax resembles that of the Perl programming language's regular expression syntax. Note The functions contained in this set were added in PHP 3.0.9 unless otherwise specified. preg_match() PHP Developer’s Dictionary IT-SC book 564 Syntax int preg_match(string pattern, mixed string [, array matches]) Description The preg_match() function searches string for any items that match the pattern . If the optional matches array variable is passed, the results are stored in that array. Otherwise, it returns 1 if a match was found, and 0 if not. preg_match ("/ll/", "Hello ,World!."); // returns 1 preg_match_all() Syntax int preg_match_all(string pattern, mixed subject, array matches [, int order]) Description The preg_match_all() function searches string for any items that match the pattern and stores the results in the matches array. If the optional parameter is passed, the storing of the matched values are in order , which can be one of the items listed in Table 11.24 : Table 11.24. Values for the order Parameter Value Description PREG_PATTERN_ORDER Orders results so that $matches[0] is an array of full pattern matches, whereas $matches[1] is an array of strings matched by the first parenthesized subpattern. PREG_SET_ORDER Orders results so that $matches[0] is an array of the first set of matches, and $matches[1] is the second set. preg_replace() Syntax mixed preg_replace(string pattern, mixed replacement, mixed string [, int limit]) . function, which was added in PHP 4.0.2, returns the image formats supported by your build of PHP. The following items represent what can be returned: • IMG_GIF PHP Developer’s Dictionary IT-SC. regular expression functions available in PHP. The discussion is broken into "Native PHP& quot; and "Perl Semantics" sections. Native PHP These sets of functions are for performing. PHP Developer’s Dictionary IT-SC book 560 The imagettfbbox() function, which was added in PHP 3.0.1, calculates, based on the size , angle