doulian1852
doulian1852
2014-03-29 22:16

使用递归函数来模拟多维数组

已采纳

below is my array...

  Array(

    [Open+Sans] => Array
      (
        [0] => normal
        [1] => lightitalic
        [2] => light
        [3] => semibold
      )

    [Nova+Script] => Array
      (
        [0] => normal
      )

    [Nova+Slim] => Array
      (
        [0] => normal
      )

    [Old+Standard+TT] => Array
      (
        [0] => normal
      )
  )

I want the keys to be imploded with | and child array to be imploded with commas, the final expected string will be like below:

Open+Sans:normal, lightitalic,light,semibold | Nova+Script:normal | Nova+Slim:normal | Old+Standard+TT:normal

thanks for your time..

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dpp3047 dpp3047 7年前

    Ich guess this should work

    $output;
    foreach($input_array as $k => $v){
        output.= $k.":";
        output.= implode(",",$v);
        output.= "|";
    }
    
    点赞 评论 复制链接分享

相关推荐