I want to remove a complete row from a 2D array in javascript where there is a specific id. I have searched and I cant find any examples. How can I achieve this?
I have an object / array like this...
[
{"id":"1","title":"Sample Event 1\n","start":"Nov 27 2011 10:30:00 GMT+0000 (GMT)","end":"Nov 27 2011 11:30:00 GMT+0000 (GMT)","allDay":false},
{"id":"2","title":"Sample Event 2","start":"Nov 28 2011 12:30:00 GMT+0000 (GMT)","end":"Dec 01 2011 12:30:00 GMT+0000 (GMT)","allDay":true},
{"id":"3","title":"Sample Event 3\n","start":"Nov 27 2011 11:30:00 GMT+0000 (GMT)","end":"Nov 27 2011 12:30:00 GMT+0000 (GMT)","allDay":false}
]
My data is pulled from a mysql database via php and json_encoded like below...
var eventObject = <?php echo json_encode($events);?>;
My problem is, if i wanted to remove a complete row eg one where id == 1 for example how could i achieve this?
I have tried using the remove attribute but this failed.
I have also tried using splice in the following manner
var eventLocation = eventObject.indexOf(EventId);
eventObject.splice(11,1);
but to no avail. Please can anyone assist?