I have following array in one of my php file and i want to return that through another file
set-info.php
<?php
return [
'email' => [
'[email protected]',
'[email protected]',
]
this is what i tried
public function getInfo()
{
//read file contents from file
$filename =$_SERVER['DOCUMENT_ROOT'].'/set-info.php';
$filename = str_replace(" ", "", $filename);
if (file_exists($filename)) {
$str = file($filename);
$str = file_get_contents($filename);
return $str;
}
}
im getting whole contents with php tags as output. how to get only php array ? pls advice ];
file_get_contentsprobably want's to be anincludeorrequire.function arraymaker (){$myarray=['apple','orange']; return $myarray;}$arr = include "set-info.php";