0) { $bgurl = "http://www.biblegateway.com/bible?version=ESV&"; #you probably wouldn't hardcode the ESV into the link list($xmldata, $esvurl) = get_query_info($q); list($querytype, $readable) = parse_query_info($xmldata, $q); if ($querytype) { $bglink = "$bgurl$querytype=" . urlencode($readable); #here you would probably go straight to the Bible Gateway: # header("Location: $bglink"); } else { #otherwise there was an error. We don't do anything with it, but you could do: # print htmlspecialchars($xmldata); } } function get_query_info($q) { #ask the ESV server to get information about the query global $key; $q = urlencode($q); $url = "http://www.gnpcb.org/esv/share/get/?key=$key&action=getQueryInfo&q=$q"; $ch = curl_init($url); #we use curl; if you don't have it installed, you'll need to try something else--an include()? curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $xmldata = curl_exec($ch); curl_close ($ch); return array($xmldata, $url); } function parse_query_info($xmldata, $q) { #get the information we need to make the string if (strpos($xmldata, "")) { #will never be at position 0, so we don't need to check true/false return array("", ""); } if (strpos($xmldata, "passage")) { #if it's a passage $bgtype = "passage"; preg_match("/([^<]*?)