PHP-在同一数组中使用相同的数组值

PHP-在同一数组中使用相同的数组值,php,arrays,Php,Arrays,我有一个长数组,例如: $userLogs = array( 'report-abuse-key' => array( 'name' => null, 'path' => null, 'code' => 'report-abuse-page', 'header' => 'Would you like to proceed?', 'link-in-navigation-menu'=

我有一个长数组,例如:

$userLogs = array(
    'report-abuse-key' => array(
        'name' => null,
        'path' => null,
        'code' => 'report-abuse-page',
        'header' => 'Would you like to proceed?',
        'link-in-navigation-menu'=>null,
        'navigation-menu-in-page'=>'Show',
        'meta'=>array(
            'show'=>null,
            'title'=>'//GET HEADER VALUE HERE//',
            'description'=>null,
            'keywords'=>null,
            'refresh'=>null,
            'canonical'=>null,
            'noindex-tag'=>'Show',//'null' = Do SEO; 'Show' = No SEO;  
            ),
        ),
);
我想从
$userLogs['header']
中获取值,并将其复制到
$userLogs['meta']['title']
中,也就是说,我希望它在不使用复制/粘贴的情况下自动复制和更新。

您可以使用。您需要将
标题
变量的引用分配给
标题
变量。在此之后,
标题
值将引用
标题
标题
中的任何更新也将更新
标题

<?php
$userLogs = array(
    'report-abuse-key' => array(
        'name' => null,
        'path' => null,
        'code' => 'report-abuse-page',
        'header' => 'Would you like to proceed?',
        'link-in-navigation-menu'=>null,
        'navigation-menu-in-page'=>'Show',
        'meta'=>array(
            'show'=>null,
            'title'=>'//GET HEADER VALUE HERE//',
            'description'=>null,
            'keywords'=>null,
            'refresh'=>null,
            'canonical'=>null,
            'noindex-tag'=>'Show',//'null' = Do SEO; 'Show' = No SEO;  
            ),
        ),
);

$userLogs['report-abuse-key']['meta']['title'] = &$userLogs['report-abuse-key']['header'];

$userLogs['report-abuse-key']['meta']['title'] = 'Updated';
echo '<pre>';
print_r($userLogs);exit;

您不能直接分配
'title'=>$userLogs['header'],
吗?您好。它不起作用。你能写你的代码部分吗,到目前为止你实现了什么来实现这一点?嗨,上面是。。。这就是阵列。我想复制
'header'=>'你想继续吗?',
在'title'=>'//在这里获取header值//',你必须解释你想做什么,你的问题听起来不符合逻辑,可能是。最好添加
print\r
@ImranZahoor的结果也添加了结果集。谢谢
Array
(
    [report-abuse-key] => Array
        (
            [name] => 
            [path] => 
            [code] => report-abuse-page
            [header] => Updated
            [link-in-navigation-menu] => 
            [navigation-menu-in-page] => Show
            [meta] => Array
                (
                    [show] => 
                    [title] => Updated
                    [description] => 
                    [keywords] => 
                    [refresh] => 
                    [canonical] => 
                    [noindex-tag] => Show
                )

        )

)