本文整理汇总了PHP中MyDB::UpdateTimeZone方法的典型用法代码示例。如果您正苦于以下问题:PHP MyDB::UpdateTimeZone方法的具体用法?PHP MyDB::UpdateTimeZone怎么用?PHP MyDB::UpdateTimeZone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyDB
的用法示例。
在下文中一共展示了MyDB::UpdateTimeZone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: csvToJson
function csvToJson($filename, $separator = ",")
{
//create the resulting array
$result = array("records" => array());
//check if the file handle is valid
//echo $filename;
if (($handle = fopen($filename, "r")) !== false) {
//"Contact","Company","Business Email","Business Phone","Direct Phone","Time Zone","Fax","Web","Source"
//check if the provided file has the right format
if (($data = fgetcsv($handle, 4096, $separator)) == false || ($data[0] != "Contact" || $data[1] != "Company" || $data[2] != "Business Email")) {
throw new InvalidImportFileFormatException(sprintf('The provided file (%s) has the wrong format!', $filename));
}
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully\n";
}
//loop through your data
while (($data = fgetcsv($handle, 4096, $separator)) !== false) {
$TZ = $db->UpdateTimeZone($data[3]);
echo json_encode($TZ);
//store each line in the resulting array
$result['records'][] = array("Contact" => $data[0], "Business Email" => $data[2], "Business Phone" => $data[3], "Time Zone" => $TZ);
}
//close the filehandle
$db->close();
fclose($handle);
}
//return the json encoded result
//echo json_encode($result);
return;
}