|
Hello World!
Comments:
Post a Comment
|
|
get_elements_by_tagname("entry"); foreach($entries as $entry) { $story_array[$counter] = new xml_story(); $element = $entry; $titles = $element->get_elements_by_tagname("title"); $title = $titles[0]; $story_array[$counter]->headline = $title->get_content(); $publish = $element->get_elements_by_tagname("published"); $date = $publish[0]; $story_array[$counter]->date = getDateFormat($date->get_content()); $content = $element->get_elements_by_tagname("content"); $description = $content[0]; $story_array[$counter]->description = $description->get_content(); $links = $element->get_elements_by_tagname("link"); $link = $links[0]; $href = $link->get_attribute_node("href"); $story_array[$counter]->href = $href->value(); $counter++; $labels = $element->get_elements_by_tagname("category"); foreach($labels as $label){ $labelTerm = $label->get_attribute_node("term"); $flag = 0; for($x = 0; $x < sizeof($labelArray); $x++){ if($labelArray[$x]['label'] == $labelTerm->value()){ $labelArray[$x]['num']++; $flag = 1; break; } } if($flag == 0){ $tempArray = array(); $tempArray['label'] = $labelTerm->value(); $tempArray['num'] = 1; $labelArray[sizeof($labelArray)] = $tempArray; } } } function getDateFormat($stamp){ $T = strrpos($stamp,"T"); $date = substr($stamp,0,$T); $year = substr($date,0,4); $month = substr($date,5,2); $day = substr($date,8,2); $time = substr($stamp,$T); $hour = substr($time,1,2); $min = substr($time,4,2); $format = "F jS, Y g:ia"; return date($format, mktime($hour, $min, 0, $month, $day, $year)); } ?>
|
Hello World!
Comments:
Post a Comment
|
|