代码
1 function arrayeval($array, $level = 0) {
2 $space = '';
3 for($i = 0; $i <= $level; $i++) {
4 $space .= "\t";
5 }
6 $evaluate = "Array\n$space(\n";
7 $comma = $space;
8 foreach($array as $key => $val) {
9 $key = is_string($key) ? '\''.addcslashes($key, '\'\\').'\'' : $key;
10 $val = !is_array($val) && (!preg_match("/^\-?\d+$/", $val) || strlen($val) > 12 || substr($val, 0, 1)=='0') ? '\''.addcslashes($val, '\'\\').'\'' : $val;
11 if(is_array($val)) {
12 $evaluate .= "$comma$key => ".arrayeval($val, $level + 1);
13 } else {
14 $evaluate .= "$comma$key => $val";
15 }
16 $comma = ",\n$space";
17 }
18 $evaluate .= "\n$space)";
19 return $evaluate;
20 }
2 $space = '';
3 for($i = 0; $i <= $level; $i++) {
4 $space .= "\t";
5 }
6 $evaluate = "Array\n$space(\n";
7 $comma = $space;
8 foreach($array as $key => $val) {
9 $key = is_string($key) ? '\''.addcslashes($key, '\'\\').'\'' : $key;
10 $val = !is_array($val) && (!preg_match("/^\-?\d+$/", $val) || strlen($val) > 12 || substr($val, 0, 1)=='0') ? '\''.addcslashes($val, '\'\\').'\'' : $val;
11 if(is_array($val)) {
12 $evaluate .= "$comma$key => ".arrayeval($val, $level + 1);
13 } else {
14 $evaluate .= "$comma$key => $val";
15 }
16 $comma = ",\n$space";
17 }
18 $evaluate .= "\n$space)";
19 return $evaluate;
20 }
形式如下:
代码
$_SCONFIG=Array
(
'sitename' => '我的空间',
'template' => 'default',
'adminemail' => 'webmaster@localhost:8080',
'onlinehold' => 1800,
'timeoffset' => 8,
'maxpage' => 100,
'starcredit' => 100,
'starlevelnum' => 5,
'cachemode' => 'database',
'cachegrade' => '0',
'allowcache' => 1,
'allowdomain' => '0',
'allowrewrite' => '0',
'allowwatermark' => '0',
'allowftp' => '0',
'holddomain' => 'www|*blog*|*space*|x',
'mtagminnum' => 5,
'feedday' => 7,
'feedmaxnum' => 100,
'feedfilternum' => 10,
'importnum' => 100,
'maxreward' => 10,
'singlesent' => 50,
'groupnum' => 8,
'closeregister' => '0',
'closeinvite' => '0',
'close' => '0',
'networkpublic' => 1,
'networkpage' => 1,
'seccode_register' => 1,
'uc_tagrelated' => 1,
'manualmoderator' => 1,
'linkguide' => 1,
'showall' => 1,
'sendmailday' => '0',
'realname' => '0',
'namecheck' => '0',
'namechange' => '0',
'name_allowviewspace' => 1,
'name_allowfriend' => 1,
'name_allowpoke' => 1,
'name_allowdoing' => 1,
'name_allowblog' => '0',
'name_allowalbum' => '0',
'name_allowthread' => '0',
'name_allowshare' => '0',
'name_allowcomment' => '0',
'name_allowpost' => '0',
'showallfriendnum' => 10,
'feedtargetblank' => 1,
'feedread' => 1,
'feedhotnum' => 3,
'feedhotday' => 2,
'feedhotmin' => 3,
'feedhiddenicon' => 'friend,profile,task,wall',
'uc_tagrelatedtime' => 86400,
'privacy' => Array
(
'view' => Array
(
'index' => '0',
'profile' => '0',
'friend' => '0',
'wall' => '0',
'feed' => '0',
'mtag' => '0',
'event' => '0',
'doing' => '0',
'blog' => '0',
'album' => '0',
'share' => '0',
'poll' => '0'
),
'feed' => Array
(
'doing' => 1,
'blog' => 1,
'upload' => 1,
'share' => 1,
'poll' => 1,
'joinpoll' => 1,
'thread' => 1,
'post' => 1,
'mtag' => 1,
'event' => 1,
'join' => 1,
'friend' => 1,
'comment' => 1,
'show' => 1,
'spaceopen' => 1,
'credit' => 1,
'invite' => 1,
'task' => 1,
'profile' => 1,
'album' => 1,
'click' => 1
)
),
'cronnextrun' => 1275469800,
'my_status' => '0',
'uniqueemail' => 1,
'updatestat' => 1,
'my_showgift' => 1,
'topcachetime' => 60,
'newspacenum' => 3,
'sitekey' => 'd9b1f883EE39e476'
)
(
'sitename' => '我的空间',
'template' => 'default',
'adminemail' => 'webmaster@localhost:8080',
'onlinehold' => 1800,
'timeoffset' => 8,
'maxpage' => 100,
'starcredit' => 100,
'starlevelnum' => 5,
'cachemode' => 'database',
'cachegrade' => '0',
'allowcache' => 1,
'allowdomain' => '0',
'allowrewrite' => '0',
'allowwatermark' => '0',
'allowftp' => '0',
'holddomain' => 'www|*blog*|*space*|x',
'mtagminnum' => 5,
'feedday' => 7,
'feedmaxnum' => 100,
'feedfilternum' => 10,
'importnum' => 100,
'maxreward' => 10,
'singlesent' => 50,
'groupnum' => 8,
'closeregister' => '0',
'closeinvite' => '0',
'close' => '0',
'networkpublic' => 1,
'networkpage' => 1,
'seccode_register' => 1,
'uc_tagrelated' => 1,
'manualmoderator' => 1,
'linkguide' => 1,
'showall' => 1,
'sendmailday' => '0',
'realname' => '0',
'namecheck' => '0',
'namechange' => '0',
'name_allowviewspace' => 1,
'name_allowfriend' => 1,
'name_allowpoke' => 1,
'name_allowdoing' => 1,
'name_allowblog' => '0',
'name_allowalbum' => '0',
'name_allowthread' => '0',
'name_allowshare' => '0',
'name_allowcomment' => '0',
'name_allowpost' => '0',
'showallfriendnum' => 10,
'feedtargetblank' => 1,
'feedread' => 1,
'feedhotnum' => 3,
'feedhotday' => 2,
'feedhotmin' => 3,
'feedhiddenicon' => 'friend,profile,task,wall',
'uc_tagrelatedtime' => 86400,
'privacy' => Array
(
'view' => Array
(
'index' => '0',
'profile' => '0',
'friend' => '0',
'wall' => '0',
'feed' => '0',
'mtag' => '0',
'event' => '0',
'doing' => '0',
'blog' => '0',
'album' => '0',
'share' => '0',
'poll' => '0'
),
'feed' => Array
(
'doing' => 1,
'blog' => 1,
'upload' => 1,
'share' => 1,
'poll' => 1,
'joinpoll' => 1,
'thread' => 1,
'post' => 1,
'mtag' => 1,
'event' => 1,
'join' => 1,
'friend' => 1,
'comment' => 1,
'show' => 1,
'spaceopen' => 1,
'credit' => 1,
'invite' => 1,
'task' => 1,
'profile' => 1,
'album' => 1,
'click' => 1
)
),
'cronnextrun' => 1275469800,
'my_status' => '0',
'uniqueemail' => 1,
'updatestat' => 1,
'my_showgift' => 1,
'topcachetime' => 60,
'newspacenum' => 3,
'sitekey' => 'd9b1f883EE39e476'
)