,我已經試過的代碼,但
//這使主由phpExcel Library導入函數返回的數組
$mdar = phpexcel_import($path);
arrange_array($mdar[0]);
function arrange_array($mdar){
$mainarr = array();
$arr = array();
$j = count($mdar);
for($a = 0 ; $a <=$j ; $a++){
if(!empty($mdar[$a]['Menu Category']))
{
$b = next_point($mdar,$a,$j);
$mainarr[$mdar[$a]['Menu Category']] = arrange_array2($mdar,$a,($b-1));
$arr = $mainarr;
}
}
}
function next_point($mdar,$last,$j){
//echo 'next_point $mdar '.$mdar.'next_point $last '.$last.' next_point $j '.$j .'<br>';
for($a = $last ; $a <=$j ; $a++){
if(!empty($mdar[$a]['Menu Category']))
{
$arr[] = $a;
}
}
return $arr[1];
}
function arrange_array2($mdar,$sp,$lp){
$arr = array();
for($a = $sp ; $a <=$lp ; $a++){
if(!empty($mdar[$a]['Menu Item']))
{
$b = next_point2($mdar,$a,$lp);
$mainarr[$mdar[$a]['Menu Item']] = arrange_array3($mdar,$a,$b);
$arr = $mainarr;
}
}
return $arr;
}
function next_point2($mdar,$last,$j){
// echo 'next_point2 $mdar '.$mdar.' next_point2 $last '.$last.' next_point2 $j '.$j .'<br>';
for($a = $last ; $a <=$j ; $a++){
if(!empty($mdar[$a]['Menu Item'])){
$arr[] = $a;
}
}
echo "next point 2 ";
print_r($arr);
return ($arr[1])?$arr[1]-1:$arr[0];
}
function arrange_array3($mdar,$sp,$lp){
//echo 'next_point2 $mdar '.$mdar.' next_point2 $sp '.$sp.' next_point2 $j '.$lp .'<br>';
$arr = array();
for($a = $sp ; $a <=$lp ; $a++){
if(!empty($mdar[$a]['Menu Item option type']))
{
$b = next_point3($mdar,$a,$lp);
$mainarr[$mdar[$a]['Menu Item option type']] = arrange_array4($mdar,$a,$b);
$arr = $mainarr;
}
}
return $arr;
}
function next_point3($mdar,$last,$j){
// echo 'next_point2 $mdar '.$mdar.' next_point2 $last '.$last.' next_point2 $j '.$j .'<br>';
for($a = $last ; $a <=$j ; $a++){
if(!empty($mdar[$a]['Menu Item option type']))
{
$arr[] = $a;
}
}
return ($arr[1])?$arr[1]-1:$arr[0];
}
function arrange_array4($mdar,$sp,$lp){
for($a = $sp ; $a <=$lp ; $a++){
if(!empty($mdar[$a]['Menu Option Values']))
{
$arr[] = $mdar[$a]['Menu Option Values'];
}
}
return $arr;
}
您是否嘗試過任何沒有? – Sirko
使用類似[PHPExcel](http://phpexcel.codeplex.com)的庫讀取Excel文件並使用庫toArray()方法;然後操作該數組以獲得所需的確切結構。 –