$valuesForLoop['dataAllComments'][$key]["user_id"] = $val['user_id'];
                    $valuesForLoop['dataAllComments'][$key]["userpic"] = "img/startyfree.jpg";
                } else {
                    $valuesForLoop['dataAllComments'][$key]["username"] = $userData["nickname"] != "" ? $userData["nickname"] : $userData["username"];
                    $valuesForLoop['dataAllComments'][$key]["user_id"] = $val['user_id'];
                    $valuesForLoop['dataAllComments'][$key]["userpic"] = $userData["userpic"] != "" ? "http://tiary.jp/s/pjpic/" . $userData["userpic"] : "img/startyfree.jpg";
                }
            } else {
                $valuesForLoop['dataAllComments'][$key]["username"] = "******";
                $valuesForLoop['dataAllComments'][$key]["user_id"] = "";
                $valuesForLoop['dataAllComments'][$key]["userpic"] = "https://press.tiary.jp/img/startyfree.jpg";
            }
            $valuesForLoop['dataAllComments'][$key]["comment"] = $val['comment'];
            $valuesForLoop['dataAllComments'][$key]["pic_url"] = $val['pic_url'];
            $valuesForLoop['dataAllComments'][$key]["addtime"] = $val['addtime'];
        }
    } else {
        $PAGE_VALUE['comment_message_on1'] = "<!--";
        $PAGE_VALUE['comment_message_on2'] = "-->";
        $PAGE_VALUE['comment_message_off1'] = "";
        $PAGE_VALUE['comment_message_off2'] = "";
    }
} else {
    header('Location: index.php');
}
$template_file = "detail.template";
//テンプレートファイルの読込
$templateData = $ins_ipfTemplate->loadTemplate($template_file);
$templateData = $ins_ipfTemplate->makeTemplateData($templateData, $PAGE_VALUE, $valuesForLoop);
$ins_ipfTemplate->putMemory($templateData);
$ins_ipfTemplate->view();
);

$values2[0] = array(
			"name" => "2日本太郎",
			"address" => "2東京都皇居1-1-1",
			"email" => "*****@*****.**"
);
$values2[1] = array(
			"name" => "2東京花子",
			"address" => "2東京都東京区2-2-2",
			"email" => "*****@*****.**"
);

$templateData2 = $a->loadTemplate("hoge2.template");//明示的にテンプレートファイルを指定する
foreach($values as $value){
	 $result2 .= $a->makeTemplateData($templateData2, $value);//「.=」である点に注意
}

//本物のループのためのデータ
$valuesForLoop["loophoge"] = $values;
$valuesForLoop["loophoge2"] = $values2;

//print_r($valuesForLoop);

//普通のPRINTのサンプル&ループの結果を入れる
$templateData = $a->loadTemplate();//デフォルトでスクリプト名と同じテンプレートが読まれる
$forTemplate[hoge] = "テストだよ〜";
$forTemplate[hoge2] = "テストだよ〜2";
$forTemplate[loop_dayo] = $result2;//ここでループの結果を代入
$result = $a->makeTemplateData($templateData, $forTemplate, $valuesForLoop);