title: Make a sub array based on main array value
body: <p>I have two arrays first array is main comment and second array is sub comment.</p>
  
  <h2>1st Array</h2>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; 1
              [comment] =&gt; Nice Blog
              [parent_id] =&gt; 0
              [created] =&gt; 2018-02-20 00:00:00
              [user_title] =&gt; Shaishav Desai
              [image_path] =&gt; 067da3ff3b891981caa5b5d98c44052c.png
              [cnt] =&gt; 
          )
  
      [1] =&gt; Array
          (
              [id] =&gt; 2
              [comment] =&gt; Awesome blog
              [parent_id] =&gt; 0
              [created] =&gt; 2018-02-20 00:00:00
              [user_title] =&gt; Lead1 Assistant
              [image_path] =&gt; 099dbe4c58606a3abf867d821e62fdf9.png
              [cnt] =&gt; 2
          )
  )
  </code></pre>
  
  <h2>2nd Array</h2>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; 3
              [comment] =&gt; Yes, Really good
              [parent_id] =&gt; 2
              [created] =&gt; 2018-02-20 00:00:00
              [user_title] =&gt; Shaishav Desai
              [image_path] =&gt; 067da3ff3b891981caa5b5d98c44052c.png
          )
  
      [1] =&gt; Array
          (
              [id] =&gt; 4
              [comment] =&gt; Thank you
              [parent_id] =&gt; 2
              [created] =&gt; 2018-02-20 00:00:00
              [user_title] =&gt; Lead1 Assistant
              [image_path] =&gt; 099dbe4c58606a3abf867d821e62fdf9.png
          )
  
  )
  </code></pre>
  
  <p>Now we need an array like this with a single array based on "parent_id" and "id":</p>
  
  <p>I want new array like this :</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [id] =&gt; 1
              [comment] =&gt; Nice Blog
              [parent_id] =&gt; 0
              [created] =&gt; 2018-02-20 00:00:00
              [user_title] =&gt; Shaishav Desai
              [image_path] =&gt; 067da3ff3b891981caa5b5d98c44052c.png
              [cnt] =&gt; 
          )
  
      [1] =&gt; Array
          (
              [id] =&gt; 2
              [comment] =&gt; Awesome blog
              [parent_id] =&gt; 0
              [created] =&gt; 2018-02-20 00:00:00
              [user_title] =&gt; Lead1 Assistant
              [image_path] =&gt; 099dbe4c58606a3abf867d821e62fdf9.png
              [cnt] =&gt; 2
              [sub_comment] =&gt; Array
              (
                  [0] =&gt; Array
                      (
                          [id] =&gt; 3
                          [comment] =&gt; Yes, Really good
                          [parent_id] =&gt; 2
                          [created] =&gt; 2018-02-20 00:00:00
                          [user_title] =&gt; Shaishav Desai
                          [image_path] =&gt; 067da3ff3b891981caa5b5d98c44052c.png
                      )
  
                  [1] =&gt; Array
                      (
                          [id] =&gt; 4
                          [comment] =&gt; Thank you
                          [parent_id] =&gt; 2
                          [created] =&gt; 2018-02-20 00:00:00
                          [user_title] =&gt; Lead1 Assistant
                          [image_path] =&gt; 099dbe4c58606a3abf867d821e62fdf9.png
                      )
  
              )
          )
  
  )
  </code></pre>
  
  <p>So I can easily know this comment have sub comment and display based on new array.
  Would you please let me know is it possible or not ?</p>
  
  <p>Thanks in advance.</p>