0
我在導出restler3 rc5中的csv格式的響應時遇到問題。無法以csv格式在Restler 3中導出響應rc5
public function downloadCSV()
{
$array = array(
"foo", "bar"
);
return $array;
}
我有支持的格式線
$r->setSupportedFormats('CsvFormat', 'JsonFormat');
,但我得到一個空的CSV。
請幫我解決這個問題。如果有任何標準數組格式,我們需要返回將其轉換爲csv。請寄給我格式。
我在以下頁面
供應商/ Luracast /格式/ CsvFormat.php
public function encode($data, $humanReadable = false)
{
$char = Object::$separatorChar;
Object::$separatorChar = false;
$data = Object::toArray($data);
Object::$separatorChar = $char;
if (is_array($data) && array_values($data) == $data) {
//if indexed array
$lines = array();
$row = array_shift($data);
if (array_values($row) != $row) {
$lines[] = static::putRow(array_keys($row));
}
$lines[] = static::putRow(array_values($row));
foreach ($data as $row) {
$lines[] = static::putRow(array_values($row));
}
return implode(PHP_EOL, $lines) . PHP_EOL;
}
throw new RestException(
500,
'Unsupported data for ' . strtoupper(static::EXTENSION) . ' format'
);
}
的問題是正在被退回其中$線在上述情況下空檢查(即
因爲$行不數組其唯一的文字有$array = array("foo", "bar");
的(array_keys($行)和array_values($行)線路中的編碼功能是空的。
我被困在裏面好幾個小時。
任何幫助,高度讚賞。