码迷,mamicode.com
首页 > 编程语言 > 详细

在PHP中如何把数组写成配置文件

时间:2018-09-17 11:34:22      阅读:313      评论:0      收藏:0      [点我收藏+]

标签:filename   dump   var_dump   配置   使用   ace   name   如何   code   

1、配置文件

<?php 
 return array (
  556770 => ‘65460d6684dcad3d0a92f1feb7fde199‘,
  567701 => ‘9c2acd2db8787c27d68f997ec49b013b‘,
  570983 => ‘7ff5f63282ad3c9d234a09025143d8b2‘,
  552162 => ‘5d70e27ed69bf83725d19505869ceb31‘,
  555203 => ‘c5cbaced05833ba3f8de3a0c13e301b4‘,
  538722 => ‘5f5632558a8f8d1e092b8087b148754b‘,
  542035 => ‘e37db8dee0da4cd9a18e85c5c55d6c98‘,
  542036 => ‘6864cddc50ebf1ba96862e09a3a6bd80‘,
  583686 => ‘4f3c42988f4154271b9d430a4d34a591‘,
  503388 => ‘67eac663a19a4d030445f1847a845669‘,
  552993 => ‘adae98b62ae5f6662749e0f93c84ed8c‘,
  542237 => ‘fdcb93166ff3159ac0e44744b90d87ca‘,
  579251 => ‘590253f71017d84ca0d00d34c686333a‘,
  592314 => ‘7b283d05d597d7049e3800aa73a77ffd‘,
  538902 => ‘2067f003ee86df72166f6d83841392b6‘,
  507719 => ‘01849069049972940cddbffe46fc44ac‘,
  577399 => ‘094604272a56d093825063db3a726f03‘,
  514302 => ‘1d15b26cdeef8d86913a8e162b32fbd8‘,
  506640 => ‘fa785771dcfce36d294e114a8477955e‘,
  503502 => ‘a786c6b54b1a1fc9da1e56336823194c‘,
  591992 => ‘3f38689d0915d11efaad34dc1aa240eb‘,
  515667 => ‘81932a1bd34973250232caa26fd7b496‘,
  538461 => ‘5fae6571c9263ef3791b91722f1b3372‘,
  512976 => ‘77958723805cfa1405f588c22bf550a2‘,
  528532 => ‘1369273015fbc6d9112262d9194839e6‘,
  541756 => ‘90246a5dedfd43df876f678624ee25e5‘,
  581727 => ‘232e6c8640fc2fbd585893293fdd76a7‘,
  559196 => ‘42c84c09b91afc1a097b040461991deb‘,
  505659 => ‘fdaef69f656988b3b01e9d3dee367962‘,
  513649 => ‘8751a7424593c635628e4031e24bf45f‘,
  507040 => ‘d299ea4018d44b6d599b4d02ee0fb51e‘,
  594555 => ‘be87c3a1a65e6435c8dc0a9b7af924ed‘,
  1 => ‘sun‘,
  2 => ‘sun‘,
);

 

2、使用配置文件

$filename=  dirname(dirname(dirname(__FILE__))) . ‘/include/configure/config.php‘;
$arr = require_once($filename);
var_dump($arr);

 

3、写入配置文件

$a = var_export($arr,true);

file_put_contents($filename,"<?php \n return ".$a.‘;‘);

 

在PHP中如何把数组写成配置文件

标签:filename   dump   var_dump   配置   使用   ace   name   如何   code   

原文地址:https://www.cnblogs.com/sunshenggang/p/9660825.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!