3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = json_decode('{"client":"4","gateWay":"1","store":"store.shop.com", "valid":"true","po":34535,"additionalPO":23423,"customerNotes":"", "orderItems":[{"item":"123","quantity":10,"supplierLotNo":"", "customsValue":"","customsDescription":"","hsCode":""}, {"item":"345","quantity":50}], "shippingInfos":[{"address":{"city":"Chennai", "country":"India","postalCode":"86715","state":"TN", "streetAddress1":"6971 North Street","streetAddress2":null}, "contact":{"company":null,"email":"info@store.com","firstName":"test", "lastName":"test","phoneNo":null},"ServiceId":"3","thirdPartyAccountNo":"", "signatureConfirmation":false,"saturdayDelivery":false}]}',true); function getUniqueObjectKeyPaths($array, $parentKey = "") { $keys = []; foreach ($array as $parentKey => $v) { if (is_array($v)) { $nestedKeys = getUniqueObjectKeyPaths($v, $parentKey); foreach($nestedKeys as $index => $key) { if (!is_numeric($parentKey) && !is_numeric($key)) { $nestedKeys[$index] = $parentKey . "->" . $key; } } array_push($keys, ...$nestedKeys); } elseif (!is_numeric($parentKey)) { $keys[] = $parentKey; } } return $keys; } var_export(getUniqueObjectKeyPaths($array));

preferences:
27.18 ms | 402 KiB | 5 Q