") $close_tag Name of the closing tag (i.e. "") ***********************************************************************/ function parse_array($string, $beg_tag, $close_tag) { preg_match_all("($beg_tag(.*)$close_tag)siU", $string, $matching_data); return $matching_data[0]; } /*********************************************************************** $value = get_attribute($tag, $attribute) ------------------------------------------------------------- DESCRIPTION: Returns the value of an attribute in a given tag. INPUT: $tag The tag that contains the attribute $attribute The name of the attribute, whose value you seek ***********************************************************************/ function get_attribute($tag, $attribute) { # Use Tidy library to 'clean' input $cleaned_html = tidy_html($tag); # Remove all line feeds from the string $cleaned_html = str_replace("\r", "", $cleaned_html); $cleaned_html = str_replace("\n", "", $cleaned_html); # Use return_between() to find the properly quoted value for the attribute return return_between($cleaned_html, strtoupper($attribute)."=\"", "\"", EXCL); } /*********************************************************************** remove($string, $open_tag, $close_tag) ------------------------------------------------------------- DESCRIPTION: Removes all text between $open_tag and $close_tag INPUT: $string The target of your parse $open_tag The starting delimitor $close_tag The ending delimitor ***********************************************************************/ function remove($string, $open_tag, $close_tag) { # Get array of things that should be removed from the input string $remove_array = parse_array($string, $open_tag, $close_tag); # Remove each occurrence of each array element from string; for($xx=0; $xx true, 'wrap' => 800); $tidy = new tidy; $tidy->parseString($input_string, $config, 'utf8'); $tidy->cleanRepair(); $cleaned_html = tidy_get_output($tidy); } } else { # Tidy not configured for this computer $cleaned_html = $input_string; } return $cleaned_html; }