3v4l.org

run code in 300+ PHP versions simultaneously
<?php header("Access-Control-Allow-Origin: *"); $json_string = '{ "nodes": [ { "id": "0", "type": "food" }, { "id": "1", "type": "drinks" }, { "id": "2", "type": "snacks" }, { "id": "3", "type": "food" }, { "id": "4", "type": "drinks" } ], "links": [ { "source": "0", "target": "1"}, { "source": "1", "target": "2"}, { "source": "2", "target": "0"} ] }'; // converts json_string to array $json = json_decode($json_string); printf("%s\n", json_encode($json, JSON_PRETTY_PRINT)); unset($json -> nodes[3]); printf("%s\n", json_encode($json, JSON_PRETTY_PRINT)); $json = array_values($json); $json = json_encode($json); printf("%s\n", $json) ?>

preferences:
24.83 ms | 408 KiB | 5 Q