title: How to insert a new key value pair in array in php?
body: <p>I've an array as follows named <code>$test_package_data</code>. For the reference I'm printing first two elements of it:</p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [test_pack_id] =&gt; 9f27643023a83addd5eed41c4aade840
              [test_pack_name] =&gt; Exams Combo
              [test_pack_desc] =&gt; This Package contains 24 tests of Reasoning, English and Quantitative Aptitude.
  
  Total Tests in this Package : 26
              [test_pack_type_id] =&gt; 3
              [test_pack_image] =&gt; 
              [test_pack_validity_year] =&gt; 0
              [test_pack_validity_month] =&gt; 3
              [test_pack_validity_days] =&gt; 0
              [test_pack_plan] =&gt; paid
              [test_pack_price] =&gt; 399.00
              [test_pack_no_tests] =&gt; 0
              [test_pack_publish] =&gt; yes
              [test_pack_sold] =&gt; 1
              [test_pack_created_staff_id] =&gt; ff8d4a5ea6bf11dce105aa2fa7b959b8
              [test_pack_updated_staff_id] =&gt; 81c4e3607c7e56bbf5461ef150437675
              [test_pack_created_date] =&gt; 303
              [test_pack_updated_date] =&gt; 1349235701
              [test_pack_purchase_date] =&gt; 255
              [category_detail] =&gt; Array
                  (
                      [0] =&gt; Array
                          (
                              [test_pack_category_id] =&gt; 8
                              [category_name] =&gt; English Language
                              [test_detail] =&gt; Array
                                  (
                                      [0] =&gt; Array
                                          (
                                              [test_id] =&gt; 91
                                              [test_name] =&gt; English Language 8
                                          )
  
                                      [1] =&gt; Array
                                          (
                                              [test_id] =&gt; 90
                                              [test_name] =&gt; English Language 7
                                          )
  
                                      [2] =&gt; Array
                                          (
                                              [test_id] =&gt; 88
                                              [test_name] =&gt; English Language 6
                                          )
  
                                      [3] =&gt; Array
                                          (
                                              [test_id] =&gt; 89
                                              [test_name] =&gt; English Language 5
                                          )
  
                                      [4] =&gt; Array
                                          (
                                              [test_id] =&gt; 87
                                              [test_name] =&gt; English Language 4
                                          )
  
                                      [5] =&gt; Array
                                          (
                                              [test_id] =&gt; 86
                                              [test_name] =&gt; English Language 3
                                          )
  
                                      [6] =&gt; Array
                                          (
                                              [test_id] =&gt; 85
                                              [test_name] =&gt; English Language 2
                                          )
  
                                      [7] =&gt; Array
                                          (
                                              [test_id] =&gt; 97
                                              [test_name] =&gt; English Language 1
                                          )
  
                                  )
  
                          )
  
                      [1] =&gt; Array
                          (
                              [test_pack_category_id] =&gt; 4
                              [category_name] =&gt; All Subjects
                              [test_detail] =&gt; Array
                                  (
                                      [0] =&gt; Array
                                          (
                                              [test_id] =&gt; 93
                                              [test_name] =&gt; Mega 2
                                          )
  
                                      [1] =&gt; Array
                                          (
                                              [test_id] =&gt; 92
                                              [test_name] =&gt; Mega 1
                                          )
  
                                  )
  
                          )
  
                      [2] =&gt; Array
                          (
                              [test_pack_category_id] =&gt; 7
                              [category_name] =&gt; Quantitative Aptitude
                              [test_detail] =&gt; Array
                                  (
                                      [0] =&gt; Array
                                          (
                                              [test_id] =&gt; 83
                                              [test_name] =&gt; Quantitative Aptitude 8
                                          )
  
                                      [1] =&gt; Array
                                          (
                                              [test_id] =&gt; 82
                                              [test_name] =&gt; Quantitative Aptitude 7
                                          )
  
                                      [2] =&gt; Array
                                          (
                                              [test_id] =&gt; 81
                                              [test_name] =&gt; Quantitative Aptitude 6
                                          )
  
                                      [3] =&gt; Array
                                          (
                                              [test_id] =&gt; 80
                                              [test_name] =&gt; Quantitative Aptitude 5
                                          )
  
                                      [4] =&gt; Array
                                          (
                                              [test_id] =&gt; 79
                                              [test_name] =&gt; Quantitative Aptitude 4
                                          )
  
                                      [5] =&gt; Array
                                          (
                                              [test_id] =&gt; 78
                                              [test_name] =&gt; Quantitative Aptitude 3
                                          )
  
                                      [6] =&gt; Array
                                          (
                                              [test_id] =&gt; 77
                                              [test_name] =&gt; Quantitative Aptitude 2
                                          )
  
                                      [7] =&gt; Array
                                          (
                                              [test_id] =&gt; 76
                                              [test_name] =&gt; Quantitative Aptitude 1
                                          )
  
                                  )
  
                          )
  
                      [3] =&gt; Array
                          (
                              [test_pack_category_id] =&gt; 6
                              [category_name] =&gt; Logical Reasoning
                              [test_detail] =&gt; Array
                                  (
                                      [0] =&gt; Array
                                          (
                                              [test_id] =&gt; 75
                                              [test_name] =&gt; Reasoning 8
                                          )
  
                                      [1] =&gt; Array
                                          (
                                              [test_id] =&gt; 74
                                              [test_name] =&gt; Reasoning 7
                                          )
  
                                      [2] =&gt; Array
                                          (
                                              [test_id] =&gt; 73
                                              [test_name] =&gt; Reasoning 6
                                          )
  
                                      [3] =&gt; Array
                                          (
                                              [test_id] =&gt; 72
                                              [test_name] =&gt; Reasoning 5
                                          )
  
                                      [4] =&gt; Array
                                          (
                                              [test_id] =&gt; 71
                                              [test_name] =&gt; Reasoning 4
                                          )
  
                                      [5] =&gt; Array
                                          (
                                              [test_id] =&gt; 70
                                              [test_name] =&gt; Reasoning 3
                                          )
  
                                      [6] =&gt; Array
                                          (
                                              [test_id] =&gt; 69
                                              [test_name] =&gt; Reasoning 2
                                          )
  
                                      [7] =&gt; Array
                                          (
                                              [test_id] =&gt; 68
                                              [test_name] =&gt; Reasoning 1
                                          )
  
                                  )
  
                          )
  
                  )
  
          )
  
      [1] =&gt; Array
          (
              [test_pack_id] =&gt; e7e95de96987cc7c89c1f0183110fb38
              [test_pack_name] =&gt; Aptitude Reasoning
              [test_pack_desc] =&gt; This package contains 8 tests on Reasoning.
              [test_pack_type_id] =&gt; 3
              [test_pack_image] =&gt; 
              [test_pack_validity_year] =&gt; 0
              [test_pack_validity_month] =&gt; 3
              [test_pack_validity_days] =&gt; 0
              [test_pack_plan] =&gt; free
              [test_pack_price] =&gt; 0.00
              [test_pack_no_tests] =&gt; 0
              [test_pack_publish] =&gt; yes
              [test_pack_sold] =&gt; 4
              [test_pack_created_staff_id] =&gt; ff8d4a5ea6bf11dce105aa2fa7b959b8
              [test_pack_updated_staff_id] =&gt; ff8d4a5ea6bf11dce105aa2fa7b959b8
              [test_pack_created_date] =&gt; 303
              [test_pack_updated_date] =&gt; 1347127387
              [test_pack_purchase_date] =&gt; 110
              [category_detail] =&gt; Array
                  (
                      [0] =&gt; Array
                          (
                              [test_pack_category_id] =&gt; 6
                              [category_name] =&gt; Logical Reasoning
                              [test_detail] =&gt; Array
                                  (
                                      [0] =&gt; Array
                                          (
                                              [test_id] =&gt; 75
                                              [test_name] =&gt; Reasoning 8
                                          )
  
                                      [1] =&gt; Array
                                          (
                                              [test_id] =&gt; 74
                                              [test_name] =&gt; Reasoning 7
                                          )
  
                                      [2] =&gt; Array
                                          (
                                              [test_id] =&gt; 73
                                              [test_name] =&gt; Reasoning 6
                                          )
  
                                      [3] =&gt; Array
                                          (
                                              [test_id] =&gt; 72
                                              [test_name] =&gt; Reasoning 5
                                          )
  
                                      [4] =&gt; Array
                                          (
                                              [test_id] =&gt; 71
                                              [test_name] =&gt; Reasoning 4
                                          )
  
                                      [5] =&gt; Array
                                          (
                                              [test_id] =&gt; 70
                                              [test_name] =&gt; Reasoning 3
                                          )
  
                                      [6] =&gt; Array
                                          (
                                              [test_id] =&gt; 69
                                              [test_name] =&gt; Reasoning 2
                                          )
  
                                      [7] =&gt; Array
                                          (
                                              [test_id] =&gt; 68
                                              [test_name] =&gt; Reasoning 1
                                          )
  
                                  )
  
                          )
  
                  )
  
          )
  )
  </code></pre>
  
  <p>Now I want to add a new key-value pair named <code>[count] =&gt; '$some_value'</code> in this array in every element after the key-value pair <code>[test_pack_purchase_date]</code>(say after <code>[test_pack_purchase_date] =&gt; 255</code>. How should I do this? Can anyone help me in this regard? Thanks in advance.</p>