Demonstration of converting a website into a function
"; echo "Information about the zipcode $zipcode
"; echo "City = ". $zip_code_array['CITY']."
"; echo "State = ". $zip_code_array['STATE']."
"; echo "County = ". $zip_code_array['COUNTY']."
"; echo "Latitude = ". $zip_code_array['LATITUDE']."
"; echo "Longitude = ". $zip_code_array['LONGITUDE']."
"; #--------------------------------------------------------------------- # Start interface describe_zipcode($zipcode) function describe_zipcode($zipcode) { # Get required libraries and declare the target include ("LIB_http.php"); include("LIB_parse.php"); $target = "http://www.schrenk.com/nostarch/webbots/zip_code_form.php"; # Download the target $page = http_get($target, $ref=""); # Parse the session hidden tag from the downloaded page # $session_tag = return_between($string = $page['FILE'] , $start = "", $type = EXCL); # Remove the "'s and "value=" text to reveal the session value $session_value = str_replace("\"", "", $session_tag); $session_value = str_replace("value=", "", $session_value); # Submit the form $data_array['session'] = $session_value; $data_array['zipcode'] = $zipcode; $data_array['Submit'] = "Submit"; $form_result = http_post_form($target, $ref=$target, $data_array); $landmark = "Information about ".$zipcode; $table_array = parse_array($form_result['FILE'], ""); for($xx=0; $xx", EXCL); $ret['CITY'] = strip_tags($ret['CITY']); $ret['STATE'] = return_between($table_array[$xx], "STATE", "", EXCL); $ret['STATE'] = strip_tags($ret['STATE']); $ret['COUNTY'] = return_between($table_array[$xx], "COUNTY", "", EXCL); $ret['COUNTY'] = strip_tags($ret['COUNTY']); $ret['LATITUDE'] = return_between($table_array[$xx], "LATITUDE", "", EXCL); $ret['LATITUDE'] = strip_tags($ret['LATITUDE']); $ret['LONGITUDE'] = return_between($table_array[$xx], "LONGITUDE", "", EXCL); $ret['LONGITUDE'] = strip_tags($ret['LONGITUDE']); } } # Return the parsed data return $ret; } # End Interface describe_zipcode($zipcode) ?>