0

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..

user1718343
  • 725
  • 2
  • 9
  • 18
  • possible duplicate of [Implode data from a multi-dimensional array](http://stackoverflow.com/questions/16710800/implode-data-from-a-multi-dimensional-array) – eggyal Mar 29 '14 at 22:17
  • 1
    why not use json_encode()? then you'll end up with a string in a common and widely used format rather than your own custom format – andrew Mar 29 '14 at 22:25

1 Answers1

1

Ich guess this should work

$output;
foreach($input_array as $k => $v){
    output.= $k.":";
    output.= implode(",",$v);
    output.= "|";
}
Bowdzone
  • 3,827
  • 11
  • 39
  • 52
  • worked like charm.. highly appreciated your input.. the only thing was to check recursive is its array and implode again.. but I modified and worked as desired.. cheers – user1718343 Mar 29 '14 at 22:45