<?php $jsonData = '[{"id":"1","component":"crank","brand":"part1","date_":"13\/11\/2019"},{"id":"2","component":"rim","date_":"13\/11\/2019","location":"Front","servicetype":"part 2"},{"id":"3","component":"bar","brand":"part 3","date_":"13\/11\/2019"}]'; $id = 2; $dataToSort = json_decode($jsonData); foreach($dataToSort as $Key => $element) { if ($element->id == $id) { unset($dataToSort[$Key]); echo $id . " Deleted\n"; } } $newJsonData = json_encode(array_values($dataToSort), JSON_PRETTY_PRINT); echo $newJsonData;
You have javascript disabled. You will not be able to edit any code.