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'], "