Jump to content

Help with switch


Bifter

Recommended Posts

Hi all,

 

I have the following:

<?php
// Varibles
$switch_type = $_GET['st'];
$switch_speed = $_GET['ss'];
$switch_size = $_GET['ssize'];

// Managed or Unmanaged
if ($_GET['st'] == "managed"){
$a1 = "answer-left";
}
else if ($_GET['st'] == "unmanaged"){
$a1 = "answer-right";
}
else if ($_GET['st'] == "smart"){
$a1 = "answer-mid";
}
else {
echo "";
}

//2nd line
$a2 = "answer";

// Type of switch
switch($_GET['st']) {
  case "managed":
    $a2 = $a1 + "-left"; break;
  case "unmanaged":
    $a2 = $a1 + "-right"; break;
  case "smart":
    $a2 = $a1 + "-mid"; break;
}

// speed of switch
if (isset($_GET['ss'])) {
switch($_GET['ss']) {
  case 100:
    $a2 = $a2 + "-left"; break;
  case 1000:
    $a2 = $a2 + "-right"; break;
}
}
echo $a1. "<br />";
echo $a2. "<br />";
?>

 

The problem is that $a2 always echo's 0 - am I missing something? Also is there a better way of doing this?

Link to comment
https://forums.phpfreaks.com/topic/180992-help-with-switch/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.