$foo = array(
  'workflowid' => '',
  'ishtml' => '0',
  'content_ishtml' => '0',
  'create_to_html_root' => '0',
  'template_list' => 'default',
  'category_template' => 'category',
  'list_template' => 'list',
  'show_template' => 'show',
  'meta_title' => '医院动态Title',
  'meta_keywords' => '医院动态Keywords',
  'meta_description' => '医院动态Description',
  'presentpoint' => '1',
  'defaultchargepoint' => '0',
  'paytype' => '0',
  'repeatchargedays' => '1',
  'category_ruleid' => '6',
  'show_ruleid' => '16',);
echo "Hello {$foo['meta_title']}!"; 这样是可以赋值,但我用
$foo2 = $rsfl[setting];(数据库读的值)$rsfl[setting]=array(
  'workflowid' => '', 'ishtml' => '0',....);
这样输出echo "Hello {$foo2['meta_title']}!"; 变成 Hello a;
请问一下这个要怎么赋值啊
还有一个二维数组又怎么赋值array (
  1 => 
  array (
    'linkurl' => '',
    'imageurl' => 'http://127.0.0.1/phpcmsv9/uploadfile/2011/0319/20110319043142150.jpg',
    'alt' => '',
  ),
)
也想实现 echo $linkurl;

解决方案 »

  1.   

    $rsfl[setting] 理应写成 $rsfl['setting']
    $array[1]['linkurl']
      

  2.   

     $foo2= $rsfl['setting'];
    echo "Hello {$foo2['meta_title']}!"; 这样输入还是 Hello a;
      

  3.   

    这个,你先print_r($rsfl['setting'])看看结果
      

  4.   

    array ( 'workflowid' => '', 'ishtml' => '0', 'content_ishtml' => '0', 'create_to_html_root' => '0', 'template_list' => 'default', 'category_template' => 'category', 'list_template' => 'list', 'show_template' => 'show', 'meta_title' => '医院动态Title', 'meta_keywords' => '医院动态Keywords', 'meta_description' => '医院动态Description', 'presentpoint' => '1', 'defaultchargepoint' => '0', 'paytype' => '0', 'repeatchargedays' => '1', 'category_ruleid' => '6', 'show_ruleid' => '16', )那样就输出这个数组了啊。我是想等到上面的值如'meta_title' 这个的值
      

  5.   

    $rsfl=$db->fetch_first("select * from v9_category  where catid=49");
    // echo $rsfl['setting'];
    $a= $rsfl['setting'];
    我就想等到数组里的值如echo $a['meta_title']";  
      

  6.   

    $arr = array ( 'workflowid' => '', 'ishtml' => '0', 'content_ishtml' => '0', 'create_to_html_root' => '0', 'template_list' => 'default', 'category_template' => 'category', 'list_template' => 'list', 'show_template' => 'show', 'meta_title' => '医院动态Title', 'meta_keywords' => '医院动态Keywords', 'meta_description' => '医院动态Description', 'presentpoint' => '1', 'defaultchargepoint' => '0', 'paytype' => '0', 'repeatchargedays' => '1', 'category_ruleid' => '6', 'show_ruleid' => '16', );
    echo "Hello".$arr['meta_title'];二维的你就用:数组名[键值][键值];还有你的
    $rsfl=$db->fetch_first("select * from v9_category where catid=49");
    // echo $rsfl['setting'];
    $a= $rsfl['setting'];
    我就想等到数组里的值如echo $a['meta_title']"; 
    这块$rsfl['setting']是个数组??
    如果不是数组,你直接echo $a就可以了.如果是个数组那你echo $rsfl['setting'][键值];
      

  7.   

    $arr = array ( 'workflowid' => '', 'ishtml' => '0', 'content_ishtml' => '0', 'create_to_html_root' => '0', 'template_list' => 'default', 'category_template' => 'category', 'list_template' => 'list', 'show_template' => 'show', 'meta_title' => '医院动态Title', 'meta_keywords' => '医院动态Keywords', 'meta_description' => '医院动态Description', 'presentpoint' => '1', 'defaultchargepoint' => '0', 'paytype' => '0', 'repeatchargedays' => '1', 'category_ruleid' => '6', 'show_ruleid' => '16', );//$rsfl['setting']$a= $rsfl['setting'];echo "Hello".$a['meta_title'];上面这样是可以得到值但我上面的数组是数组库中赋值才是这样的。
      

  8.   

    你的代码不完整,只看到数据库查询结果赋值给了$rsfl
    完全不知道$rsfl['setting']从哪来
      

  9.   

    $rsfl=$db->fetch_first("select * from v9_category  where catid=49");
    // echo $rsfl[setting];
    $a= $rsfl['setting'];(是数组)
    echo "Hello".$a['meta_title'];
      
      

  10.   

    纠结,抓狂把print_r($rsfl)的结果贴出来看看,注意不是$rsfl['setting']
      

  11.   

    Array ( [catid] => 49 [siteid] => 1 [module] => content [type] => 0 [modelid] => 1 [parentid] => 0 [arrparentid] => 0 [child] => 0 [arrchildid] => 49 [catname] => 医院动态 [style] => [image] => [description] => [parentdir] => [catdir] => yydt [url] => http://127.0.0.1/phpcmsv9/index.php?m=content&c=index&a=lists&catid=49 [items] => 2 [hits] => 0 [setting] => array ( 'workflowid' => '', 'ishtml' => '0', 'content_ishtml' => '0', 'create_to_html_root' => '0', 'template_list' => 'default', 'category_template' => 'category', 'list_template' => 'list', 'show_template' => 'show', 'meta_title' => '医院动态Title', 'meta_keywords' => '医院动态Keywords', 'meta_description' => '医院动态Description', 'presentpoint' => '1', 'defaultchargepoint' => '0', 'paytype' => '0', 'repeatchargedays' => '1', 'category_ruleid' => '6', 'show_ruleid' => '16', ) [listorder] => 49 [ismenu] => 1 [sethtml] => 0 [letter] => yiyuandongtai [usable_type] => ) 
    就是这样啊。
      

  12.   

    在$a= $rsfl['setting'];这句后面
    逐个测试:
    echo $rsfl['catname'],"<br>",PHP_EOL;
    echo $rsfl['setting']['meta_title'],"<br>",PHP_EOL;
    if (is_array($a)) echo "True<br>",PHP_EOL;
    echo $a['meta_title'],"<br>",PHP_EOL;
      

  13.   

    if (is_array($rsfl['setting'])) echo "True<br>",PHP_EOL;这个呢?
      

  14.   

    这就说明$rsfl['setting']不是数组很怀疑它是一个内容为
    array ( 'workflowid' => '', 'ishtml' => '0', 'content_ishtml' => '0', 'create_to_html_root' => '0', 'template_list' => 'default', 'category_template' => 'category', 'list_template' => 'list', 'show_template' => 'show', 'meta_title' => '医院动态Title', 'meta_keywords' => '医院动态Keywords', 'meta_description' => '医院动态Description', 'presentpoint' => '1', 'defaultchargepoint' => '0', 'paytype' => '0', 'repeatchargedays' => '1', 'category_ruleid' => '6', 'show_ruleid' => '16', ) 
    字符串继续测试:
    eval($rsfl['setting']);
    if (is_array($rsfl['setting'])) echo "True<br>",PHP_EOL;结果如何?
      

  15.   

    sorry,测试语句写错了,应该这样:
    $b='$c='.$rsfl['setting'];
    eval($b);
    if (is_array($c)) echo "True<br>",PHP_EOL;
      

  16.   

    eval()'d code 报这个错了
      

  17.   

    if (is_string($rsfl['setting'])) echo "True<br>",PHP_EOL;
      

  18.   

    ……就是说这个$rsfl['setting']是字符串啊,不是数组,正如我17楼说的……
    大爷我今天心情好,不然早甩你几个耳光了去看手册eval函数,把它转出为数组
    我现在要去忙了,楼下谁接手?
      

  19.   

    但我setting这个字段的值是array (
      'workflowid' => '',
      'ishtml' => '0',
      'content_ishtml' => '0',
      'create_to_html_root' => '0',
      'template_list' => 'default',
      'category_template' => 'category',
      'list_template' => 'list',
      'show_template' => 'show',
      'meta_title' => '医院动态Title',
      'meta_keywords' => '医院动态Keywords',
      'meta_description' => '医院动态Description',
      'presentpoint' => '1',
      'defaultchargepoint' => '0',
      'paytype' => '0',
      'repeatchargedays' => '1',
      'category_ruleid' => '6',
      'show_ruleid' => '16',
    )这样啊。。
      

  20.   

    算了,纠结,再来$b='$c='.$rsfl['setting'].';';
    eval($b);
    if (is_array($c)) echo "True<br>",PHP_EOL;
    如果最后显示true的话,$c就是你想要的数组
      

  21.   

    是显示TRUE,我现在就想知道 'meta_title' => '医院动态Title',
    怎么样得到医院动态Title这个