0

I am in middle of PHP script. I am trying to check if variable $type22 is equal a first string if not check if variable $type22 is equal to the second string and (so on) and if the variable is the equal to the string, put another related string value in a variable called $s22 to be used later.

This is what I have so far but it keeps choosing the first if string value only even if the condition is not true and return $s22 value = userbouquet.favourites.tv even if &type22 is not equal gigablue or enigma16 or dreambox. Please help me as I am very confused

                if ($type22 = "gigablue") {
                    $s22 = 'userbouquet.favourites.tv';
                
                } else if ($type22 = "enigma16") {
                    $s22 = 'userbouquet.favourites.tv';
                
                } else if ($type22 = "dreambox") {
                    $s22 = 'userbouquet.favourites.tv';
                
                } else if ($type22 = "m3u") {
                    $s22 = "tv_channels_$username.m3u";
                
                } else if ($type22 = "simple") {
                    $s22 = "simple_$username.txt";
                
                } else if ($type22 = 'octagon') {
                    $s22 = 'internettv.feed';
                
                } else if ($type22 = 'starlivev3') {
                    $s22 = 'iptvlist.txt';
                
                } else if ($type22 = 'mediastar') {
                    $s22 = 'tvlist.txt';
                
                } else if ($type22 = 'enigma216_script') {
                    $s22 = 'iptv.sh';
                
                } else if ($type22 = 'enigma22_script') {
                    $s22 = 'iptv.sh';
                
                } else if ($type22 = 'm3u_plus') {
                    $s22 = "tv_channels_$username_plus.m3u";
                
                } else if ($type22 = 'm3u_web') {
                    $s22 = 'playlist.m3u';
                
                } else if ($type22 = 'webtvlist') {
                    $s22 = 'webtv list.txt';
                
                } else if ($type22 = 'octagon_script') {
                    $s22 = 'iptv';
                
                } else if ($type22 = 'ariva') {
                    $s2 = "ariva_$username.txt";
                
                } else if ($type22 = 'spark') {
                    $s22 = 'webtv_usr.xml';
                
                } else if ($type22 = 'gst') {
                    $s22 = "$username_list.txt";
                
                } else if ($type22 = 'fps') {
                    $s22 = 'Royal.cfg';
                
                } else if ($type22 = 'revosun') {
                    $s22 = 'network_iptv.cfg';
                
                } else if ($type22 = 'zorro') {
                    $s = 'iptv22.cfg';
                }

1 Answers1

0

It's probably easier to read if you use an array.

<?php
$type22 = 'some_value';

$map = [
    "gigablue" => 'userbouquet.favourites.tv',
    "enigma16" => 'userbouquet.favourites.tv',
    "dreambox" => 'userbouquet.favourites.tv',
    "m3u" => "tv_channels_$username.m3u",
    "simple" => "simple_$username.txt",
    'octagon' => 'internettv.feed',
    'starlivev3' => 'iptvlist.txt',
    'mediastar' => 'tvlist.txt',
    'enigma216_script' => 'iptv.sh',
    'enigma22_script' => 'iptv.sh',
    'm3u_plus' => "tv_channels_$username_plus.m3u",
    'm3u_web' => 'playlist.m3u',
    'webtvlist' => 'webtv list.txt',
    'octagon_script' => 'iptv',
    'ariva' => "ariva_$username.txt",
    'spark' => 'webtv_usr.xml',
    'gst' => "$username_list.txt",
    'fps' => 'Royal.cfg',
    'revosun' => 'network_iptv.cfg',
    'zorro' => 'iptv22.cfg',
];

$s22 = isset($map[$type22]) ? $map[$type22] : null;
echo $s22;
bassxzero
  • 4,838
  • 22
  • 34