我如何在另一个 php 文件中的数组中写入键值对 [英] How can i write key value pair in array in another php file

查看:35
本文介绍了我如何在另一个 php 文件中的数组中写入键值对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 phpfile let,xyz.php 并且从这个文件我必须更新另一个 phpfile 让它的名字,abc.php

i have one phpfile let,xyz.php and from this file i have to update another phpfile let its name,abc.php

我怎样才能达到我想要的输出.

how can i do this to achieve my desired output.

xyz.php

<?php    

//need code for update $GLOBALS['app_list_strings']['ip_list'] array present in xyz.php
?> 

abc.php

$GLOBALS['app_list_strings']['ip_list']=array (
  '192.168.1.51' => 'server1',
  // i have to add key and value pair here just like above from xyz.php
);
?>

推荐答案

变量 $_GLOBAL 不是必需的.您还可以使用:

The variable $_GLOBAL is not necessary. You can also use:

 return array();

$data = require '../path/to/my/file.php';

这篇关于我如何在另一个 php 文件中的数组中写入键值对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆