如何從 PHP 文件加載返回數組? - How to load return array from a PHP file?

問題:

I have a PHP file a configuration file coming from a Yii message translation file which contains this:我有一個 PHP 文件,一個來自Yii消息翻譯文件的配置文件,其中包含以下內容:

<?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");
}

$in is the filename of the PHP file $in是 PHP 文件的文件名

Any thoughts how to do this?任何想法如何做到這一點?


解決方案:

參考: https://stackoom.com/en/question/TgBU
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章