如何从PHP文件加载返回数组? [英] How to load return array from a PHP file?

查看:260
本文介绍了如何从PHP文件加载返回数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP文件从到来的Yii 消息翻译文件的配置文件,其中包含这样的:

I have a PHP file a configuration file coming from a Yii message translation file which contains this:

<?php
 return array(
  'key' => 'value'
  'key2' => 'value'
 );
?>

我想从另一个文件加载这个数组并将其存储在一个变量

I want to load this array from another file and store it in a variable

我试图做到这一点,但它不能正常工作

I tried to do this but it doesn't work

function fetchArray($in)
{
   include("$in");
}

$在是PHP文件的文件名

任何思考如何做到这一点?

Any thoughts how to do this?

推荐答案

当包含的文件返回的东西,你可以简单地把它分配给一个变​​量

When an included file returns something, you may simply assign it to a variable

$myArray = include $in;

请参阅http://php.net/manual/en/function.include.php#example-130

这篇关于如何从PHP文件加载返回数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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