title: Recursively extract key paths from array - excluding numeric keys
body: <p>In php, I need a function to return all keys in array of objects. For arrays and objects I need keys like <code>parentkey-&gt;key</code>.  If the key is again an array, then I need <code>parentkey-&gt;key-&gt;key1</code>.</p>
  <p><strong>My code as below</strong></p>
  <pre><code>$array=json_decode('{&quot;client&quot;:&quot;4&quot;,&quot;gateWay&quot;:&quot;1&quot;,&quot;store&quot;:&quot;store.shop.com&quot;,
  &quot;valid&quot;:&quot;true&quot;,&quot;po&quot;:34535,&quot;additionalPO&quot;:23423,&quot;customerNotes&quot;:&quot;&quot;,
  &quot;orderItems&quot;:[{&quot;item&quot;:&quot;123&quot;,&quot;quantity&quot;:10,&quot;supplierLotNo&quot;:&quot;&quot;,
  &quot;customsValue&quot;:&quot;&quot;,&quot;customsDescription&quot;:&quot;&quot;,&quot;hsCode&quot;:&quot;&quot;},
  {&quot;item&quot;:&quot;345&quot;,&quot;quantity&quot;:50}],
  &quot;shippingInfos&quot;:[{&quot;address&quot;:{&quot;city&quot;:&quot;Chennai&quot;,
  &quot;country&quot;:&quot;India&quot;,&quot;postalCode&quot;:&quot;86715&quot;,&quot;state&quot;:&quot;TN&quot;,
  &quot;streetAddress1&quot;:&quot;6971 North Street&quot;,&quot;streetAddress2&quot;:null},
  &quot;contact&quot;:{&quot;company&quot;:null,&quot;email&quot;:&quot;info@store.com&quot;,&quot;firstName&quot;:&quot;test&quot;,
  &quot;lastName&quot;:&quot;test&quot;,&quot;phoneNo&quot;:null},&quot;ServiceId&quot;:&quot;3&quot;,&quot;thirdPartyAccountNo&quot;:&quot;&quot;,
  &quot;signatureConfirmation&quot;:false,&quot;saturdayDelivery&quot;:false}]}',true);
  
  function array_keys_multi(array $array,$headkey,$pkey){
      $keys = array();$hkey='';$parentkey='';
      foreach ($array as $key =&gt; $value) {
          //echo $key;
          if($headkey!='' &amp;&amp; !is_integer($headkey)){
              if(!is_integer($key)){
                  if (is_array($value) || is_object($value)) {
                      if($pkey!='')
                         $parentkey=$pkey.&quot;-&gt;&quot;.$key;
                      else 
                          $parentkey=$key;
                          foreach($value as $kk=&gt;$val){
                              foreach($val as $kk1=&gt;$val1){
                                  $keys[]=$parentkey.&quot;-&gt;&quot;.$kk1;
                              }
                          }
                          //$keys[]=$parentkey.&quot;-&gt;&quot;.$key;
                  }else{
                      $keys[] = $pkey.&quot;-&gt;&quot;.$key;
                      $hkey=$headkey.&quot;-&gt;&quot;.$key;
                  }
              }
          }
          else{
              if(!is_integer($key)){
                  if($pkey!='')
                      $parentkey=$pkey.&quot;-&gt;&quot;.$key;
                  else 
                      $parentkey=$key;
                  if (is_array($value) || is_object($value)) {
                      if($pkey!='')
                          $parentkey=$pkey.&quot;-&gt;&quot;.$key;
                      else
                          $parentkey=$key;
                          foreach($value as $kk=&gt;$val){
                              //print_r($val);echo &quot;==========&quot;;
                              foreach($val as $kk1=&gt;$val1){
                                  $keys[]=$parentkey.&quot;-&gt;&quot;.$kk1;
                              }
                          }
                          $hkey=$key;
  
                  }else{
                      $keys[]=$key;
                  }
              }
          }
          
          if (is_array($value) || is_object($value)) {
              echo $key.&quot;-----&quot;.$hkey.&quot;&lt;br&gt;&quot;;
              $keys = array_merge($keys, array_keys_multi($value,$hkey,$key));
          }
      }
      return $keys;
  }
  $k=array_keys_multi($array,'','');
  print_r($k);
  </code></pre>
  <p>I need output as an array with the following key paths (notice no numeric keys are retained):</p>
  <pre><code>[
      &quot;client&quot;,
      &quot;gateWay&quot;,
      &quot;store&quot;,
      &quot;valid&quot;,
      &quot;po&quot;,
      &quot;additionalPO&quot;,
      &quot;customerNotes&quot;,
      &quot;orderItems-&gt;item&quot;,
      &quot;orderItems-&gt;quantity&quot;,
      &quot;orderItems-&gt;supplierLotNo&quot;,
      &quot;orderItems-&gt;customsValue&quot;,
      &quot;orderItems-&gt;customsDescription&quot;,
      &quot;orderItems-&gt;hsCode&quot;,
      &quot;shippingInfos-&gt;address-&gt;city&quot;,
      &quot;shippingInfos-&gt;address-&gt;country&quot;,
      &quot;shippingInfos-&gt;address-&gt;postalCode&quot;,
      &quot;shippingInfos-&gt;address-&gt;state&quot;,
      &quot;shippingInfos-&gt;address-&gt;streetAddress1&quot;,
      &quot;shippingInfos-&gt;address-&gt;streetAddress2&quot;,
      &quot;shippingInfos-&gt;contact-&gt;company&quot;,
      &quot;shippingInfos-&gt;contact-&gt;email&quot;,
      &quot;shippingInfos-&gt;contact-&gt;firstName&quot;,
      &quot;shippingInfos-&gt;contact-&gt;lastName&quot;,
      &quot;shippingInfos-&gt;contact-&gt;phoneNo&quot;,
      &quot;shippingInfos-&gt;ServiceId&quot;,
      &quot;shippingInfos-&gt;thirdPartyAccountNo&quot;,
      &quot;shippingInfos-&gt;signatureConfirmation&quot;,
      &quot;shippingInfos-&gt;saturdayDelivery&quot;
  ]
  </code></pre>
  <p>How can I achieve this?</p>