This code is currently working. It breaks the $ json variable where it is}, {but it also removes these characters, but I really need the trailing and leading brackets for the json_decode function to work. I created a job, but wondered if there is a more elegant solution?
<?php $json = '{"a":1,"b":2,"c":3,"d":4,"e":5},{"a":1,"b":2,"c":3,"d":4,"e":5}'; $individuals = preg_split('/},{/',$json); $loop_count =1; foreach($individuals as $object){ if($loop_count == 1){$object .='}';} else{$object ="{".$object;} print_r(json_decode($object)); echo '<br />'; $loop_count++; } ?>
EDIT: The $ json variable is actually retrieved as a json object. The correct example is:
[{"ID": "Foo", "row": 1, "column": 1, "height": 4, "width": 5}, {"identifier": "bar", "row": 2, "column": 3, "height": 4, "width": 5}]
Somk source share