下面是我的代码。此代码读取包含大约 100 个学生资料的 csv 文件。这些配置文件在此 HTML 页面中显示为幻灯片 - http://www.depts.ttu.edu/honors/medallion-ceremony/test/。我想为每 5 个配置文件显示一个广告幻灯片。请帮忙 !
$profiles = csv_to_array($_SERVER['DOCUMENT_ROOT'].'/...../profiles.csv');
function csv_to_array($filename, $delimiter=',', $enclosure='"', $escape = '\\')
{
if(!file_exists($filename) || !is_readable($filename)) return false;
$header = null;
$data = array();
$lines = file($filename);
foreach($lines as $line) {
$values = str_getcsv($line, $delimiter, $enclosure, $escape);
if(!$header)
$header = $values;
else
$data[] = array_combine($header, $values);
}
return $data;
}
function displayProfiles($limit=100)
{
global $profiles;
$count = 1;
foreach ($profiles as $profile)
{
if ($count <= $limit)
{
displayProfile($profile);
$count++;
}
}
}
function displayProfile($profile) {.....}