📅  最后修改于: 2022-03-11 14:54:41.229000             🧑  作者: Mango
$txt_file = file_get_contents('path/to/file.txt');
$rows = explode("\n", $txt_file);
array_shift($rows);
foreach($rows as $row => $data)
{
//get row data
$row_data = explode('^', $data);
$info[$row]['id'] = $row_data[0];
$info[$row]['name'] = $row_data[1];
$info[$row]['description'] = $row_data[2];
$info[$row]['images'] = $row_data[3];
//display data
echo 'Row ' . $row . ' ID: ' . $info[$row]['id'] . '
';
echo 'Row ' . $row . ' NAME: ' . $info[$row]['name'] . '
';
echo 'Row ' . $row . ' DESCRIPTION: ' . $info[$row]['description'] . '
';
echo 'Row ' . $row . ' IMAGES:
';
//display images
$row_images = explode(',', $info[$row]['images']);
foreach($row_images as $row_image)
{
echo ' - ' . $row_image . '
';
}
echo '
';
}