如何从同一目录中的另一个php文件中的下面代码中回显/ print_r url arry code=>'LV_ARTICLES_ARTICLECODE'
?
function BuildSearchIndex($showHomePage = False,$functionLanguage)
{
$index_arr = array
(
array
(
'directory'=>'data/articles',//bestands locatie is data/articles/ "alles"
'files_ext'=>array('xml'),//bestands extentie is "xml"
'tags'=>array //alle tags zijn tussen de <> tekens
(
'LV_ARTICLES_DESCRIPTION' //artiekel omschrijvings tag
/*,'LV_ARTICLES_DESCRIPTIONANDMEASURE',
'LV_ARTICLES_SPECIFICATION'*/,
'LV_ARTICLES_ARTICLECODE' //artiekel code / ID tag
/*,'LV_ARTICLES_ARTICLECODE2',
'LV_ARTICLES_SHORTMEMO',
'LV_ARTICLES_LONGMEMO',
'LV_ARTICLES_ARTICLECODE2'*/
),
'url'=>array
(
'action'=>'article',
/*'group_id'=>'content "/<LV_ARTICLES_GROUP>.*<LV_ARTICLES_ITEM>(.+)<\/LV_ARTICLES_ITEM>.*<\/LV_ARTICLES_GROUP>/isU"',*/
'aid'=>'filename "/article_(\d+).xml/i"'
),
'name'=>'LV_ARTICLES_DESCRIPTIONANDMEASURE',
'code'=>'LV_ARTICLES_ARTICLECODE',
'languages'=>array(),
'additional'=>array
(
'price'=>'content "/<LV_ARTICLES_PRICE_EXVAT>(.+)<\/LV_ARTICLES_PRICE_EXVAT>/iU"',
'vat'=>'content "/<LV_ARTICLES_VAT>(.+)<\/LV_ARTICLES_VAT>/iU"',
'manufacturer'=>'content "/<LV_ARTICLES_MANUFACTURER>(.+)<\/LV_ARTICLES_MANUFACTURER>/iU"',
'categories'=>'content "/<LV_ARTICLES_GROUP>(.+)<\/LV_ARTICLES_GROUP>/isU"'
)
),
array
(
'directory'=>'data/extrapages',
'files_ext'=>array('xml'),
'tags'=>array('LV_TITLE','LV_BODY'),
'url'=>array(
'action'=>'extra',
'extra'=>'filename "/(.+).xml/i"'),
'name'=>'LV_TITLE',
'languages'=>array()
)
);
$clear_arr = array
(
0=>array('dir'=>'./data/articles',
'languages'=>array()),
1=>array('dir'=>'./data/extrapages',
'languages'=>array())
);
$lang=$functionLanguage->getLanguageList();
foreach ($lang as $v)
{
$index_arr[0]['languages'][$v['code']]='LV_ARTICLES_LANG_'.strtoupper($v['code']);
$index_arr[1]['languages'][$v['code']]='LV_'.strtoupper($v['code']);
$clear_arr[0]['languages'][$v['code']]=$v['code'];
$clear_arr[1]['languages'][$v['code']]=$v['code'];
}
try
{
$q=new Search();
$q->clear_index($clear_arr);
$q->make_index($index_arr);
}
catch (Exception $e)
{
echo $e->__toString();
}
if ($showHomePage) {
header('location: index.php?action=home&lang='.strtoupper($functionLanguage->getCurrentLanguage()));
}
}
我不知道为什么我要添加更多细节。我认为我的问题很清楚。但是我尝试$index_arr['']['url']['code']
的任何方式首先它可能是错误的第二个它在一个函数中。我甚至可以从那里提取这些信息吗?
答案 0 :(得分:0)
您需要在BuildSearchIndex函数中返回$index_arr
。然后当你从另一个文件调用这个函数时,你可以这样做:
$array = BuildSearchIndex($param1, $param2);
echo $array[0]['url']['code'];
另一方面,如果你不能在函数上返回数组,那么将通过引用传递$index_arr
,做这样的事情:
function BuildSearchIndex($showHomePage = False,$functionLanguage, &$index_arr)
{
$index_arr = array
(
array
(....
然后以这种方式调用函数,您将可以访问所需的内容:
$array = array();
BuildSearchIndex($param1, $param2, $array);
echo $array[0]['url']['code'];