代码中有个typename,导出到序列化文件singerpagedate.php中得到的是“[0] => Array [typename] => 大类别1
,希望能自动生成[typename1] => 大类别1  或者   “[fenlei0] => Array,,当增加大类别就以此类推,自动fenlei0,fenlei1.如何修改代码~哪位大神可以指导一下,ManageSingerPageEdit.php
 <?php
require_once '../include/adminfunction.php';
checkadmin();function updatesettext($text){
    if($text=="")
        return "";
    $text=str_replace("'",'"',$text);
    $text=str_replace("\r","",$text);
    $text=str_replace("\n","",$text);
    return $text;
}$pageid=var_request("pageid","");
$typeid = var_request("typeid","");
$action=var_request("action","");
$tp=var_request("tp","");
$arri=var_request("i","");$arrays = application("page".$pageid,"../data/singerpagedate.php");
$pageinfo = application("singerpagelist","../data/singerpagedate.php");if(!is_array($arrays)){
    $arrays = array();
}$errmsg = "";
$pagetext="";
if($action=="update" || $action=="add"){
    
    $ctypename = updatesettext(var_request("typename",""));
    $ctypeurl = updatesettext(var_request("typeurl",""));
    $cappno = var_request("appno","0");
    $cbutton = var_request("button","0");
    
    $arrayNow = array();
    $arrayNow['typename'] = $ctypename;
    $arrayNow['typeurl'] = $ctypeurl;
        
    if($action=="add"){
        $arrayNow['keywordlist'] = array();
        array_push($arrays,$arrayNow);
    }
    if($action=="update" && $cbutton=="修改"){
        $arrays[$cappno]['typename'] = $arrayNow['typename'];
        $arrays[$cappno]['typeurl'] = $arrayNow['typeurl'];
    }
    if($action=="update" && $cbutton=="删除"){
        array_splice($arrays,$cappno,1);
    }
    setapplication("page".$pageid,$arrays,"../data/singerpagedate.php");
    
    redirect_to("ManageSingerPageEdit.php?pageid=".$pageid);
    exit;
    
}if($action=="updatelink" || $action=="addlink"){
    
    $ctitle = updatesettext(var_request("title",""));
    $cpic = updatesettext(var_request("pic",""));
    $cshoplevel = updatesettext(var_request("shoplevel",""));
    $clink = updatesettext(var_request("link",""));
    $cappno = var_request("appno","0");
    $cbutton = var_request("button","0");
    
    $arrayNow = array();
    $arrayNow['title'] = $ctitle;
    $arrayNow['pic'] = $cpic;
    $arrayNow['shoplevel'] = $cshoplevel;
    $arrayNow['link'] = $clink;
    
    
    if($action=="addlink"){
        array_push($arrays[$typeid]['keywordlist'],$arrayNow);
    }
    if($action=="updatelink" && $cbutton=="修改"){
        $arrays[$typeid]['keywordlist'][$cappno] = $arrayNow;
    }
    if($action=="updatelink" && $cbutton=="删除"){
        array_splice($arrays[$typeid]['keywordlist'],$cappno,1);
    }
    //dump($arrays);
    setapplication("page".$pageid,$arrays,"../data/singerpagedate.php");
    
    redirect_to("ManageSingerPageEdit.php?pageid=".$pageid);
    exit;
    
}?>singerpagedate.phpArray
(
    [singerpagelist] => Array
        (
            [0] => Array
                (
                    [txtname] => daohang
                    [pagekeyword] => 
                    [pagedescription] => 本模块用于首页的导航
                    [pagetitle] => 页面0
                )        )    [page0] => Array
        (
            [0] => Array
                (
                    [typename] => 大类别1
                    [typeurl] => page/1.html
                    [keywordlist] => Array
                        (
                            [0] => Array
                                (
                                    [title] => 小类别
                                    [pic] => 
                                    [shoplevel] => 0
                                    [link] => 0123.html
                                )                            [1] => Array
                                (
                                    [title] => 小类别
                                    [pic] => 
                                    [shoplevel] => 0
                                    [link] => 0123.html
                                )                        )                )            [1] => Array
                (
                    [typename] => 大类别2
                    [typeurl] => page/2.html
                    [keywordlist] => Array
                        (
                            [0] => Array
                                (
                                    [title] => 小类别
                                    [pic] => 
                                    [shoplevel] => 0
                                    [link] => 123.html
                                )                            [1] => Array
                                (
                                    [title] => 小类别
                                    [pic] => 
                                    [shoplevel] => 0
                                    [link] => 123.html
                                )                        )                )        )    [page1] => Array
        (
        )    [page5] => Array
        (
        ))

解决方案 »

  1.   

    从 singerpagedate.php 看,应该是文件缓存吧!
    你把简单的看的太复杂了。
      

  2.   

    是的 ~singerpagedate.php 是缓存文件,但我不懂PHP 能不能帮帮忙修改一下ManageSingerPageEdit.php
    <?php exit();?>a:4:{s:14:"singerpagelist";a:1:{i:0;a:4:{s:7:"txtname";s:7:"daohang";s:11:"pagekeyword";s:0:"";s:15:"pagedescription";s:30:"本模块用于首页的导航";s:9:"pagetitle";s:7:"页面0";}}s:5:"page0";a:2:{i:0;a:3:{s:8:"typename";s:10:"大类别1";s:7:"typeurl";s:11:"page/1.html";s:11:"keywordlist";a:2:{i:0;a:4:{s:5:"title";s:9:"小类别";s:3:"pic";s:0:"";s:9:"shoplevel";s:1:"0";s:4:"link";s:9:"0123.html";}i:1;a:4:{s:5:"title";s:9:"小类别";s:3:"pic";s:0:"";s:9:"shoplevel";s:1:"0";s:4:"link";s:9:"0123.html";}}}i:1;a:3:{s:8:"typename";s:10:"大类别2";s:7:"typeurl";s:11:"page/2.html";s:11:"keywordlist";a:2:{i:0;a:4:{s:5:"title";s:9:"小类别";s:3:"pic";s:0:"";s:9:"shoplevel";s:1:"0";s:4:"link";s:8:"123.html";}i:1;a:4:{s:5:"title";s:9:"小类别";s:3:"pic";s:0:"";s:9:"shoplevel";s:1:"0";s:4:"link";s:8:"123.html";}}}}s:5:"page1";a:0:{}s:5:"page5";a:0:{}}<?php exit();?>