将文件内的数组(按文件获取内容)转换为实际的php数组

将文件内的数组(按文件获取内容)转换为实际的php数组,php,arrays,Php,Arrays,我的框架中有一个语言文件,它基本上是一个数组 eng/language.php <?php return [ 'HomeSearchtTitle'=>' search what you want ! ' , 'wellcom'=>' Wellcom !' , 'ResultSuccess'=>' here is the result ' , ]; ?> 这总是返回null 你知道我该怎么做吗?来自: 可以在包含的文件中执行return语句

我的框架中有一个语言文件,它基本上是一个数组

eng/language.php

<?php
return [

    'HomeSearchtTitle'=>' search what you want ! ' ,
    'wellcom'=>' Wellcom !' ,
    'ResultSuccess'=>' here is the result ' ,
];
?>
这总是返回null

你知道我该怎么做吗?

来自:

可以在包含的文件中执行return语句,以终止该文件中的处理并返回到调用它的脚本。此外,还可以从包含的文件中返回值。您可以像对待普通函数一样接受include调用的值

这意味着您可以简单地执行以下操作:

$languageArray=include$dir_path/language.php; 要使用var_导出回写修改后的数组,请执行以下操作:

... $languageArray['new_string']='new string!'; 文件_put_contents$dir_path/language.php; 思考听起来更像你需要的。请继续你的帖子。很难理解它们。你的赏金不会有太大帮助,你可以通过遵循这些规则得到同样的效果。
$language = eval(str_replace(['<?php' , '?>' , 'return'  ] , '' , file_get_contents("$dir_path/language.php")));