/**
 * utf8_add_bom_to_string( )
 * 
 * Prepends BOM character to the string and returns the whole string.
 * If BOM already existed there, the Input string is returned.
 * @since 1.0
 * 
 * @param    string $str The input string
 * @return   string The output string that contains BOM
 */
function utf8_add_bom_to_string($str)
{
    if (!is_bom(substr($str, 0, 3))) {
        $str = utf8_bom() . $str;
    }
    return $str;
}
示例#2
0
<?php

echo utf8_bom();
$header = array();
foreach ($all_rows[0] as $cells) {
    $header[] = $cells[0];
}
echo csv_line($header);
foreach ($all_rows as $row) {
    $line = array();
    foreach ($row as $cells) {
        $line[] = $cells[1];
    }
    echo csv_line($line);
}