function SELECT( $select, $where, $is, $from ) { for( get_xml_files_and_loop ) { $xml = simplexml_load_file( xml_file ); if( $xml->$where = $is ) return $xml->$select; } return 0; } usage: SELECT( $->money, $->name, "hobbes", "xml_files/" );