Jump to content

Small Help


webstar

Recommended Posts

<?php
$file_array = file('http://www.weatherserver.net/text/CWTO/WOCN11.txt');
$subject1_words = explode(" ",$file_array[2]);
$subject1 = $subject1_words[0] . " " . $subject1_words[1];
$subject2 = $file_array[3];

echo $subject1 . "<br />";
echo $subject2 . "<br />";
?>

 

Results:

WOCN11 CWTO

SPECIAL WEATHER STATEMENT

Link to comment
Share on other sites

#!/usr/bin/php
<?php


# E-mail recipient(s).  Separate each address with a comma and a space.
$emailrecip = "removed";

# E-mail From name.
$emailfromname = "removed";

# E-mail From address.
$emailfromaddr = "removed";



$fp = fopen('php://stdin','r');
$data = "";
while(!feof($fp)) {
$new_data = fgets($fp,4096);
$data .= $new_data;
$data_array[$i++]=$new_data;
}
fclose($fp);
$patterns = array();
$patterns[0] = '/CWTO/';
$patterns[1] = '/CWWG/';
$patterns[2] = '/CWVR/';
$patterns[3] = '/CWHX/';
$patterns[4] = '/CWUL/';
$replacements = array();
$replacements[0] = '-ON-';
$replacements[1] = '-Prairies-';
$replacements[2] = '-BC-';
$replacements[3] = '-Maritimes-';
$replacements[4] = '-QC-';
$data_array = preg_replace($patterns, $replacements, $data_array);

$split_line = explode(' ', $data_array[2]);
$subject = $split_line[0].' '.$split_line[1].' '.trim($data_array[3]);



# Send the e-mail.

        $recipient = $emailrecip;
        $body_of_email = trim($data);

        $header = 'From: "' . $emailfromname . '" <' . $emailfromaddr . '>';
        $header .= "\n"; 
        $header .= "X-Priority: 1";
        $header .= "\n";

	        mail ($recipient, $subject, $body_of_email, $header);

        echo ("E-mail sent.");

?>

 

I kinda went a different direction with it.  The first 3 arrays work but the 4th one never seems to fire and I was wondering if anyone can tell me why.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.