With a little help I have ended up with the following Function:
function process_objects($data){
$pattern = "/<==OBJECTSTART==>.*?<==OBJECTEND==>/";
preg_match_all($pattern, $data, $objects);
if(!empty($objects[0])){
foreach($objects as $objectarr){
foreach($objectarr as $object){
$line = preg_replace('/<==OBJECTSTART==>(.*)<==OBJECTEND==>/', '\1', $object);
$pairs = explode(',', $line);
$new_data = array();
foreach ($pairs as $pair) {
list ($key, $value) = explode('=>', $pair);
$new_data[$key] = $value;
}
$replacement = get_object($new_data[type],$new_data[objectid],$new_data[options]);
$data = str_replace($object, $replacement, $data);
}
}
//
return $data;
}
}
function get_object($objtype, $objid, $objoptions){
$item = "<table><tr><td>this is an object: ".$objtype."</td></tr></table>\n";
return $item;
}
Seems to work, but not sure if it is the most efficient way to get there!