doulian1852
2014-03-29 22:16
浏览 73
已采纳

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

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 2014-03-29 22:40
    已采纳

    Ich guess this should work

    $output;
    foreach($input_array as $k => $v){
        output.= $k.":";
        output.= implode(",",$v);
        output.= "|";
    }
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题