使用串行键合并所有数组值

I am working on a Laravel app where the user can curate posted data with few options. So whenever user make a post he has given option to add category for that and fill more details depending on that category. On submit post data get saved with it's category id( i am saving this category and it's curated values to other table by putting it's id to post table).

array after posting data is like:

            Array
    (
  [title] => this is data 
   [subhead] => this is data this is data this is data this is data 
   [htmlcontent] => this is data this is data this is data this is data this is data this is data 
  [category] => story
   [author] => Array
    (
        [0] => author 1
        [1] => author 2
    )

[facts] => Array
    (
        [0] => facts
    )

[inspiration] => Array
    (
        [0] => insp1 
        [1] => insp2
    )

[tags] => Array
    (
        [0] => tag
    )

[refrence] => Array
    (
        [0] => ref1
        [1] => ref2
        [2] => ref3
    )

)

Now according to my situation, user can edit every single option, like he can edit author 1,2 and save it. for this i have to save every single value with identifier. Hence using author1 ,author2 to make it unique.

I have curated an option array for a post and it looks like this:

  Array ( [_id]       => 537ded7e8b5c880c1f000029
          [category]  => story 
          [author1]   => Anil Sharma 
          [author2]   => Tester 
          [citaion1]  => cited 
          [citaion2]  => cited2
          [tags]      => tag1,tag2,tag3
          [refrence1] => facebook.com
          [refrence2] => twitter
        )

And on the frontend I have to show the data like this:

   Expected Output
        category    story 
        author      Anil Sharma 
                    Tester 
        citaion     cited 
                    cited2
        tags        tag1,tag2,tag3
        refrence    facebook.com
                    twitter    


   Current Output

        category    story 
        author1      Anil Sharma 
        author2     Tester 
        citaion1     cited 
        citaion2     cited2
        tags        tag1,tag2,tag3
        refrence1    facebook.com
        refrence2    twitter                   

 HTML to show this :
    @foreach($category as $key => $value)
            <li>
             <label class="detailhead">{{$key}}</label>
             <p class="inlineedit" data-type="textarea" data-pk="{{$data->id}}" data-placement="left" data-url="{{URL::to('/')}}/ajax/post" data-title="Enter {{$key}}" id="{{$key}}_hoot">{{$value}}
             </p>

  </li>

  @endif

I can't make any change to key's name because they are the identifier for that part.On their value click user can edit the part with jQuery UI editables. User can curate any option and i have to save it accordingly. So what would be the best way to achieve this. should i make or filter array part in view section, but the thing I need to keep in mind is that whenever I am showing this thing into view I have to keep id="{{$key}}" unique in the tag. With its help, I am saving that particular curated part.

So what would be the best way for me to achieve this?

You could do this (I've stripped the html css stuff out to make it easier to read):

<?php $previousKey = null; ?>
@foreach($category as $key => $value)
      <li>
          @if ((substr($key, 0, -1) != substr($previousKey, 0, -1))
              <label class="detailhead">{{ $key }}</label>
          @endif
          <p>{{$value}}</p>
      </li>
      <?php $previousKey = $key; ?>
@endif

Its not the cleanest solution - you could refactor it to improve the code - but you get the idea. Basically it just compares the current key to the previous one with the number. So citation1 and citation2 would match, but only print the first citation key name.

How is the initial array generated? Can you change that to a better structure to make your life easier?