Jump to content

changing weather maps


hjhjhgjgjh

Recommended Posts

Hi,

ok this is what i want to do...

we are on the pilot briefing page.. the departure icao is EDDT and the arrival doesnt matter for now. the weather map should now automatically show a map of europe instead of one from america or whatever. BUT if the icao is like KJFK, it should show a map of america of course. i started like that

<?php

if (substr('$schedule->depicao', 0,1) == 'E')

{

echo '<img src="map for e.g. europe" />';

}

elseif(substr('$schedule->depicao',0,1) == 'K')

{

echo '<img src="map for e.g. north america" />';

    }

else

{

    echo 'no map available';

    }

?>

but somehow it always shows "no map available".. what did i do wrong?

Link to comment
Share on other sites

okay it works  8)

replace the code with the weather maps in that schedule_briefing.tpl with the following codes

/rmk: you can add/change the dedicated maps,.. i also dont have maps for asia and something included, because i didnt find some good ones..  This code will automatically show the weather map for departure and arrival airport(lets better say continent/country) on FL300. If the flight is longer than 3400nm, NAT maps are also included ! (Updated 12:20Z 29.10.09: Now the dep and arr maps are not the same. the dep map is a 6 hours forecast and arr is a 24 hours forecast but can be changed to 12 hours if required)

<h3>Weather</h3>

<div align="center">

<?php

            if (substr("$schedule->depicao", 0,1) == 'A')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'B')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/euwt30006.gif" />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'C')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/cnhisig12.gif" />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'D')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'E')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/euwt30006.gif" />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'F')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'G')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'H')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'I')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'J')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'K')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/uswt30006.gif" />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'L')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/euwt30006.gif" />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'M')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/mxhisig12.gif" />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'N')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'O')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'P')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'R')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'S')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'T')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'U')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'V')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'W')

            {

                echo '<b>Departure Airport</b><br /><br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'X')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'Y')

            {

                echo '<b>Departure Airport</b><br /><br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'Z')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }   

            else

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            ?>

            <?php

            if($schedule->distance >= 3400.00)

            {

            echo '<br /><br /><b><u>NAT</u></b><br /><br /><b>Eastbound</b><br /><img src="http://www.jetplan.com/weather/data/maps/ntfasig12.gif" /><br /><br /><b>Westbound</b><br /><img src="http://www.jetplan.com/weather/data/maps/ntfzsig12.gif" /><br /><br />';

            }

            ?>

            <?php

            if (substr("$schedule->arricao", 0,1) == 'A')

            {

                echo '<br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'B')

            {

                echo '<br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/euwt30012.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'C')

            {

                echo '<br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/cnhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'D')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /> <br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'E')

            {

                echo '<br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/euwt30012.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'F')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'G')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'H')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'I')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'J')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'K')

            {

                echo '<br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/uswt30024.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'L')

            {

                echo '<br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/euwt30012.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'M')

            {

                echo '<br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/mxhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'N')

            {

                echo '<br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'O')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'P')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'R')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br />" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'S')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'T')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'U')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'V')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'W')

            {

                echo '<br /><b>Arrival Airport</b><br /><br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'X')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'Y')

            {

                echo '<br /><b>Arrival Airport</b><br /><br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'Z')

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }   

            else

            {

                echo '<br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

           

           

?>

</div>

Link to comment
Share on other sites

again an update and the last for today in this script. this update automatically recognizes if your NAT is east or westbound and then shows only one map (e.g. east or westbound)

<h3>Weather</h3>

<div align="center">

<?php

            if (substr("$schedule->depicao", 0,1) == 'A')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'B')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/euwt30006.gif" />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'C')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/cnhisig12.gif" />';

                if($schedule->distance >= 3400.00)

                {

                  echo '<br /><br /><b><u>NAT Eastbound</u></b><br /><img src="http://www.jetplan.com/weather/data/maps/ntfzsig12.gif" /><br /><br />';

                } 

            }

            elseif(substr("$schedule->depicao",0,1) == 'D')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'E')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/euwt30006.gif" />';

                if($schedule->distance >= 3400.00)

                {

                  echo '<br /><br /><b><u>NAT Westbound</u></b><br /><img src="http://www.jetplan.com/weather/data/maps/ntfasig12.gif" /><br /><br />';

                }

            }

            elseif(substr("$schedule->depicao",0,1) == 'F')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'G')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'H')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'I')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'J')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'K')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/uswt30006.gif" />';

                if($schedule->distance >= 3400.00)

                {

                  echo '<br /><br /><b><u>NAT Eastbound</u></b><br /><img src="http://www.jetplan.com/weather/data/maps/ntfzsig12.gif" /><br /><br />';

                } 

            }

            elseif(substr("$schedule->depicao",0,1) == 'L')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/euwt30006.gif" />';

                if($schedule->distance >= 3400.00)

                {

                  echo '<br /><br /><b><u>NAT Westbound</u></b><br /><img src="http://www.jetplan.com/weather/data/maps/ntfasig12.gif" /><br /><br />';

                }

            }

            elseif(substr("$schedule->depicao",0,1) == 'M')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/mxhisig12.gif" />';

                if($schedule->distance >= 3400.00)

                {

                  echo '<br /><br /><b><u>NAT Eastbound</u></b><br /><img src="http://www.jetplan.com/weather/data/maps/ntfzsig12.gif" /><br /><br />';

                } 

            }

            elseif(substr("$schedule->depicao",0,1) == 'N')

            {

                echo '<b>Departure Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'O')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

                if($schedule->distance >= 3400.00)

                {

                  echo '<br /><br /><b><u>NAT Westbound</u></b><br /><img src="http://www.jetplan.com/weather/data/maps/ntfasig12.gif" /><br /><br />';

                }

            }

            elseif(substr("$schedule->depicao",0,1) == 'P')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

                if($schedule->distance >= 3400.00)

                {

                  echo '<br /><br /><b><u>NAT Eastbound</u></b><br /><img src="http://www.jetplan.com/weather/data/maps/ntfzsig12.gif" /><br /><br />';

                }   

            }

            elseif(substr("$schedule->depicao",0,1) == 'R')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'S')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'T')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'U')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'V')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'W')

            {

                echo '<b>Departure Airport</b><br /><br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'X')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'Y')

            {

                echo '<b>Departure Airport</b><br /><br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->depicao",0,1) == 'Z')

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }   

            else

            {

                echo '<b>Departure Airport</b><br /><br />no weather map available for departure airport<br /><br />';

            }

            ?>

            <?php

            if (substr("$schedule->arricao", 0,1) == 'A')

            {

                echo '<br /><br /><br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'B')

            {

                echo '<br /><br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/euwt30012.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'C')

            {

                echo '<br /><br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/cnhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'D')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /> <br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'E')

            {

                echo '<br /><br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/euwt30012.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'F')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'G')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'H')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'I')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'J')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'K')

            {

                echo '<br /><br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/uswt30024.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'L')

            {

                echo '<br /><br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/euwt30012.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'M')

            {

                echo '<br /><br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/mxhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'N')

            {

                echo '<br /><br /><b>Arrival Airport</b><br /> <br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'O')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'P')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'R')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br />" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'S')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'T')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'U')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'V')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'W')

            {

                echo '<br /><br /><b>Arrival Airport</b><br /><br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'X')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'Y')

            {

                echo '<br /><br /><b>Arrival Airport</b><br /><br /><img src="http://www.jetplan.com/weather/data/maps/auhisig12.gif" /><br /><br /><br />';

            }

            elseif(substr("$schedule->arricao",0,1) == 'Z')

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }   

            else

            {

                echo '<br /><br /><b>Arrival Airport</b><br />no weather map available for arrival airport<br /><br /><br /><br />';

            }

           

           

?>

</div>

Link to comment
Share on other sites

  • Administrators

Alot of code.

A few things, instead of substr(), you can do

$schedule->arricao[0] == 'A'

That's faster than calling substr().

You could also convert this into a function. Just some pseudocode, but the basic idea:

<?php
function getMap($letter, $type)
{
    $letter = strtoupper($letter);
    if($letter == 'A')
    { 
          // Show map info
          echo "{$type} map..... <img src=....." // etc
    }
    elseif($letter == 'B')
    {
         // Do only the letters which have maps
     }
    else
     {
         // For all others, just do the echo "no map available"
         echo "{$type} has no map available";
      }
}

// Then just call
getMap($schedule->arricao[0], 'Arrival');
getMap($schedule->depicao[0], 'Departure');

Generally, if you're repeating any code more than once, you should be using a function

http://us2.php.net/manual/en/functions.user-defined.php

Link to comment
Share on other sites

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.

Loading...
×
×
  • Create New...