$data=array(
"name"=>"222222",
"tel"=>159131,
"address"=>"广州市天河区",
"config['title']"=>"你好中",
);
if(update_config('config.php',$data)){
echo"ok";
}

     function update_config($file, $data,$type="string"){
	 if(!file_exists($file)){
	 return false;
	 }
	 if(!is_array($data)){
	 return false;
	 }
     $str=file_get_contents($file);
	 $str2=$str;
	
    
	 foreach($data as $key=>$val){
	  $pattern='/'.$key.'=(.*?)\;/i';
	  if(is_int($val)){
        $str2=preg_replace($pattern,$key.'='.$val.';',$str2);
       }else{
	  $str2=preg_replace($pattern,$key.'="'.$val.'";',$str2);
	   }
	 }
	 file_put_contents($file,$str2);
	 return true;
 }

  config.php

<?php
	$name="222222";//kkkk
    $tel=159131;
    $phone=4561321;
    $address="广州市天河区";
?>

  

相关文章:

  • 2022-01-05
  • 2021-09-17
  • 2021-07-13
  • 2021-08-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-19
  • 2021-12-04
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
相关资源
相似解决方案