开发者

Help creating selective IF statement

开发者 https://www.devze.com 2022-12-15 05:33 出处:网络
I have this code that sends a text message to your mobile phone... $text = fopen(\"../data/textmembers/registry.txt\",\"r\") or die(\"couldent open file\");

I have this code that sends a text message to your mobile phone...

$text = fopen("../data/textmembers/registry.txt","r") or die("couldent open file");

while (!feof($text)) {
$name = fgets($text);
$number = fgets($text);
$carrier = fgets($text);
$date = fgets($text);
$line = fgets($text);


$content = $_POST['message']; 

$message .= $content; 
$message .= "\n";
$number = trim($number);




mail($number . "@vtext.com", "SGA Event Alert", $message, "SGA"); 
Header("Location: mailconf.php");

everything works fine.. Here is my question, if you look at where I have "@vtext.com" as you may or may not know, each carrier has its own extension, 开发者_开发技巧verizon is @vtext.com, at&t is @txt.att.net. I need to take the feed from "$carrier" decide what carrier it is, and then assign the extension to it... I thought an ifelse would work, but I am not good with if statements... the user's choices are

Verizon = 1234567890@vtext.com AT&T = 1234567890@txt.att.net T-mobile = @tmomail.net Nextel = @messaging.nextel.com

thanks guys!!


$carriers = array(
  "verizon"  => "vtext.com",
  "at&t"     => "txt.att.net",
  "t-mobile" => "tmomail.net",
  "nextel"   => "messaging.nextel.com"
);

Then, you get that value by looking up the key:

print $carriers[strtolower($carrier)];

If $carrier is "Nextel," "messaging.nextel.com" will be returned.


Probably better than using an if statement would be using a switch statement.

Have a look at the section of the PHP manual that deals with the switch statement.

0

精彩评论

暂无评论...
验证码 换一张
取 消