从多维数组中获取值

时间:2011-07-27 20:08:28

标签: php multidimensional-array

我在下面有这个数组,需要知道var才能获得["option_value"]中的序列化字符串。我的有限理解使我相信它会$resdata[0]['option_value'],但会返回NULL

$resdata =

    array(1) { [0]=> array(5) { ["option_id"]=> string(3) "853" ["blog_id"]=> string(1) "0" ["option_name"]=> string(24) "wp_table_reloaded_data_2" ["option_value"]=> string(1125) "a:9:{s:2:"id";i:2;s:11:"category_id";s:1:"2";s:4:"name";s:20:"Copy of Test Table 1";s:11:"description";s:27:"
    This is a test table

    ";s:10:"visibility";a:2:{s:4:"rows";a:2:{i:0;b:0;i:1;b:0;}s:7:"columns";a:3:{i:0;b:0;i:1;b:0;i:2;b:0;}}s:4:"data";a:2:{i:0;a:3:{i:0;s:14:"
    test 1a

    ";i:1;s:19:"
    test 1b blah

    ";i:2;s:14:"
    test 1c

    ";}i:1;a:3:{i:0;s:14:"
    test 2a

    ";i:1;s:14:"
    test 2b

    ";i:2;s:14:"
    test 2c

    ";}}s:7:"options";a:19:{s:22:"alternating_row_colors";b:1;s:19:"print_name_position";s:5:"above";s:26:"print_description_position";s:5:"below";s:18:"cache_table_output";b:1;s:16:"custom_css_class";s:0:"";s:15:"use_tablesorter";b:1;s:15:"datatables_sort";b:1;s:19:"datatables_paginate";b:1;s:27:"datatables_paginate_entries";i:10;s:23:"datatables_lengthchange";b:1;s:17:"datatables_filter";b:1;s:15:"datatables_info";b:1;s:25:"datatables_customcommands";s:0:"";s:9:"row_hover";b:0;s:12:"first_row_th";b:0;s:12:"table_footer";b:0;s:10:"print_name";b:0;s:17:"print_description";b:0;s:21:"datatables_tabletools";b:0;}s:13:"last_modified";s:19:"2011-07-01 23:21:31";s:14:"last_editor_id";s:1:"6";}" ["autoload"]=> string(3) "yes" } }

1 个答案:

答案 0 :(得分:1)

你有什么应该工作。你是如何尝试使用它的?你想回声或打印吗?

foreach($resdata as $v){
  echo $v['option_value']
}