本文整理汇总了PHP中JUDirectoryHelper::getCSVData方法的典型用法代码示例。如果您正苦于以下问题:PHP JUDirectoryHelper::getCSVData方法的具体用法?PHP JUDirectoryHelper::getCSVData怎么用?PHP JUDirectoryHelper::getCSVData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUDirectoryHelper
的用法示例。
在下文中一共展示了JUDirectoryHelper::getCSVData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadCSVColumns
public function loadCSVColumns()
{
$app = JFactory::getApplication();
$path = $app->getUserState('file_path', '');
$delimiter = $app->getUserState('delimiter', ',');
$enclosure = $app->getUserState('enclosure', '"');
if (!JFile::exists($path)) {
$this->setError(JText::sprintf("COM_JUDIRECTORY_IMPORT_IMAGE_FILE_S_NOT_FOUND", $path));
return false;
}
$rows = JUDirectoryHelper::getCSVData($path, $delimiter, $enclosure, 'r+', 0, null, true);
$csvColumnRows = array_shift($rows);
$totalCsvRow = count($rows);
$app->setUserState('csv_total_row', $totalCsvRow);
return $csvColumnRows;
}
示例2: combineCSVColumnNameWithColumnValue
public function combineCSVColumnNameWithColumnValue()
{
$app = JFactory::getApplication();
$dataCSV = $app->getUserState('csv.dataCSV');
$config = $dataCSV['csv_config'];
$csvPath = $dataCSV['csv_file_path'];
$delimiter = $dataCSV['csv_delimiter'];
$enclosure = $dataCSV['csv_enclosure'];
$start = $app->input->getInt('start', 0);
$limit = $config['limit'];
$csvData = JUDirectoryHelper::getCSVData($csvPath, $delimiter, $enclosure, 'r+', $start, $limit, false);
$columns = $dataCSV['csv_assigned_fields'];
foreach ($csvData as $index => $data) {
if (count($columns) == count($data)) {
$csvData[$index] = array_combine($columns, $data);
} else {
unset($csvData[$index]);
}
}
return $csvData;
}