dongming6201 2013-02-12 12:06
浏览 57

要打印array.under数组的值

I have to print the all the value of the array written value.

[subscriber] => Array
    (
        [name] => Subscriber
        [capabilities] => Array
            (
                [read] => 1
                [level_0] => 1
            )
        [default] => Array
            (
                [deft] => Array (
                              [one] => 2
                              [two] => 3
                        )
                [deft_one] => Array (
                               [one] => t
                               [two] => h
                        )
            )

    )

I have to print each value under the array. So i used a recursion function. But i cant the result. Please help me in recursion function.

Sorry, I am trying till now. Actually i have to print the wp-option table value. There are many serialise array. I want to print all the value individually. I mean when i used the code written bellow i got an array.

function option_value_change () {
  global $wpdb;
  $myrows = $wpdb->get_results( "SELECT *
  FROM `wp_options`");
    $temp_url = get_option('siteurl');
    $site_url = get_site_url();
    foreach ($myrows as $rows){
      $option = get_option($rows->option_name);
                //print_r($option);
        get_option_value($option);
    }
}

i can get the table. But in an array. Which array have arrays. So i used an function "get_option_value($option)". as written bellow

function get_option_value($option) {
    if(!is_object($option) && !is_array($option)){
        echo $option;
    }
    else{
            foreach($option as $option_value){
                if(!is_array($option_value)){
                    echo $option_value;
                }
                else {
                    get_option_value($option_value);

                }
            }
    }
}

bUt i cant get all the value. its give an error as

Object of class stdClass could not be converted to string.

So how can i print all the values of the array.

  • 写回答

2条回答 默认 最新

  • duanpen9294 2013-02-12 12:17
    关注

    I didn't test it but you can get the idea;

    function printArr($obj){
    
        if(!is_array($obj)){
    
            echo $obj;
            return;
        }
        else if(is_array($obj)){
    
            foreach ($obj as $key => $value) {
                printArr($obj[$key]);
            }
        }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?