initial commit
This commit is contained in:
25
production/php/functions/func_xml.php
Normal file
25
production/php/functions/func_xml.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
################################################### FUNCTION: xml_random_child #
|
||||
function xml_random_child($xml_file)
|
||||
{
|
||||
$xml = xml_get_from_file($xml_file);
|
||||
$children = $xml->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);
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user