如何用PHP替换Google drawtable中的换行符/新行
以下内容破坏了我的google.visualization.DataTable。我从谷歌日历中提取这个如何用PHP替换Google drawtable中的换行符/新行,php,newline,google-calendar-api,line-breaks,Php,Newline,Google Calendar Api,Line Breaks,以下内容破坏了我的google.visualization.DataTable。我从谷歌日历中提取这个 // this one has a line break/enter/new line in google calendar after 5 Kanji lessons from 11 to 15 or Kanji lesson's from 1 to 5 Beginner students dont have matome quiz. They have usual Katakana qu
// this one has a line break/enter/new line in google calendar after 5
Kanji lessons from 11 to 15 or Kanji lesson's from 1 to 5
Beginner students dont have matome quiz. They have usual Katakana quiz from ta to po.
但是下面的方法很好
// this does not have it.
Kanji lessons from 11 to 15 or Kanji lesson's from 1 to 5. Beginner students dont have matome quiz. They have usual Katakana quiz from ta to po.
我尝试了以下方法。但到目前为止,他们都没有成功
$description = str_replace(" "," ",$description);
$description_arr=explode("\\n",$description);
$description = implode("<br />", $description_arr);
$description=str\u replace(“,”,$description);
$description\u arr=分解(\\n“,$description);
$description=内爆(“
,$description\u arr”);
全部代码
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['table,corechart']});
google.setOnLoadCallback(drawTable);
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// start of tabel
function drawTable() {
var data = new google.visualization.DataTable();
//data.addColumn('string', 'Calendar Name');
data.addColumn('string', 'Date Due');
data.addColumn('string', 'Summary');
data.addColumn('string', 'Date Created');
data.addColumn('string', 'Description');
data.addRows([
<?php
if(count($events))
{
foreach($events->items as $item)
{
//$displayName = str_replace("'", "\'", $item->organizer->displayName);
$summary = str_replace("'", "\'", $item->getSummary());
$datedue = str_replace("'", "\'", $item->start->date);
$description = str_replace("'", "\'", $item->description);
$description = str_replace(" "," ",$description);
// $description_arr=explode("\\n",$description);
// $description = implode("<br />", $description_arr);
echo "['".$datedue."','".$summary . "','" . substr($item->created, 0, 10) ."','".$description."' ],\n";
//echo "['".$displayName."','".$summary."','".$date . "','" . substr($item->created, 0, 10) ."','".$descrption."' ],\n";
}
}
else
{
echo "Calendar is private.";
}
?>
]);
var table = new google.visualization.Table(document.getElementById('table_div'));
table.draw(data, {showRowNumber: true, allowHtml:true});
}
// end of table
//加载可视化API和piechart包。
load('visualization','1.0',{'packages':['table,corechart']});
setOnLoadCallback(drawTable);
//将回调设置为在加载Google Visualization API时运行。
setOnLoadCallback(drawChart);
//tabel的开始
函数drawTable(){
var data=new google.visualization.DataTable();
//data.addColumn('string','Calendar Name');
data.addColumn('string','datedue');
data.addColumn('string','Summary');
data.addColumn('string','datecreated');
data.addColumn('string','Description');
data.addRows([
我在下面添加了最后两行,现在效果很好
$summary = str_replace("'", "\'", $item->getSummary());
$date = str_replace("'", "\'", $item->start->date);
$description = str_replace("'", "\'", $item->description);
// replace line breaks with a space
$description = str_replace("\n"," ",$description);
$description = str_replace("\r"," ",$description);