10) { break; } $o[] = array('title'=>$deliciousdata['TITLE'],'link'=>$deliciousdata['LINK']); $cnt++; } } return $o; } function delicious_compact_array($link) { $compacted_array = array(); $current_title = ""; $current_link = ""; if ($link) { foreach ($link as $links) { $pos = strpos($links['LINK'], 'ttp://'); if ($pos == 1) { if($current_link) { $current_title_link = array(); $current_title_link['TITLE'] = $current_title; $current_title_link['LINK'] = $current_link; $compacted_array[] = $current_title_link; } $current_link = $links['LINK']; $current_title = $links['TITLE']; } else { $current_link .= $links['LINK']; } } $current_title_link = array(); $current_title_link['TITLE'] = $current_title; $current_title_link['LINK'] = $current_link; $compacted_array[] = $current_title_link; } return $compacted_array; } function startingElement($parser, $name, $attrs) { global $item; global $succ_title; global $succ_link; global $succ_description; global $depth; if ($name == 'RDF:SEQ') { $parent = $name; } if ($parent == 'RDF:SEQ' && $name == 'RDF:LI') { foreach ($attrs as $keys => $value) { if ($keys == 'RDF:RESOURCE') { for($ct = 0;$ct < count($value); $ct++) { $values[$cnt] = $value; $cnt++; } } } } if ($name == 'ITEM') { $item = $name; foreach ($attrs as $index => $data) { if ($index == 'RDF:ABOUT') { $value = $data; } } } $depth[$parser]++; if ($name == 'TITLE' && $item == 'ITEM') { $succ_title = $name; } if ($name == 'LINK' && $item == 'ITEM') { $succ_link= $name; } if ($name == 'DESCRIPTION' && $item == 'ITEM') { $succ_description = $name; } } /** * called when ending tag is encountered */ function endingElement($parser, $name) { global $succ_title; global $succ_link; global $succ_description; if ($name == 'RDF:SEQ') { $parent = ""; } if ($name == 'TITLE') { $succ_title = ''; } if ($name == 'LINK') { $succ_link = ''; } if ($name == 'DESCRIPTION') { $succ_description = ''; } if($name == 'ITEM') { $item = ''; } $depth[$parser]--; } function fetchdata($parser,$tagdata) { global $link; global $links; global $succ_title; global $succ_link; global $succ_description; global $depth; if ($succ_title) { $links['TITLE'] = $tagdata; } if ($succ_link) { $links['LINK'] = $tagdata; } if ($succ_description) { $links['DESCRIPTION'] = $tagdata; } if ($succ_link) { $link[] = $links; } } function array2object($array) { if (is_array($array)) { $object = new StdClass(); foreach ($array as $key => $value) { $object->$key = $value; } } else { $object = $array; } return $object; } /** * Convert an object to an associative array. */ function object2array($object) { if (is_object($object)) { foreach ($object as $key => $value) { $array[$key] = $value; } } else { $array = $object; } return $array; } ?>