Microsoft Word - Core PHP Programming Using PHP to Build Dynamic Web Sites

(singke) #1

Sascha Schumann added this function specifically to break base64 codes up into 76-
character chunks. Although ereg_replace can mimic this functionality,
chunk_split is faster. It isn't appropriate for breaking prose between words. That is, it
isn't intended for performing a soft wrap.


<?


$encodedData =
chunck_split(base64_encode($rawData));
?>


string convert_cyr_string(string text, string from, string to)


Use convert_cyr_string to convert a text in one Cyrillic character set to another.


The from and to arguments are single-character codes listed in Table 9.3.


Table 9.3. Codes for convert_cyr_String
Code Description
a,d x-cp866
i iso8859-5
k koi8-r
m x-mac-cyrillic
w windows-1251


<?


$new = convert_cyr_string($old, "a", "w");
?>


string dirname(string path)


The dirname function returns only the directory part of a path. The trailing slash is not
included in the return value. Directories are understood to be separated by slashes (/). On
Windows, backslashes () may be used, too. If you need to get the filename part of a path,
use basename.


<?


$path = "/usr/local/bin/ls";
print(dirname($path));
:?>

Free download pdf