children(); $count = count($children); return($children[rand(0,$count-1)]); } ################################################## FUNCTION: xml_get_from_file # function xml_get_from_file($file_path) { if(!file_exists($file_path)) { trigger_error('XML file "'.$file_path.'" does not exist!'); return NULL; } return simplexml_load_file($file_path); } ################################################ FUNCTION: xml_nl_to_paragraph # function xml_nl_to_paragraph($string) { $string = '

'.preg_replace('#([\r\n]\s*?[\r\n]){2,}#','

$0

',$string).'

'; $string = str_replace('

','',$string); return $string; } ################################################### FUNCTION: xml_parse_bbcode # function xml_parse_bbcode($string) { $codes = array('[b]','[/b]','[i]','[/i]','[/link]'); $translation = array('','','','',''); // replace bbcode items from above $string = str_replace($codes,$translation,$string); // deal with [link]s $pattern = "#\[link href=([^\]]+)\]#"; $replacement = ""; $string = preg_replace($pattern,$replacement,$string); return $string; } ###################################################### FUNCTION: xml_fix_cdata # function xml_fix_cdata($string) { $find[] = '<![CDATA['; $replace[] = ''; return $string = str_replace($find, $replace, $string); } ?>