Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7038123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:37:52+00:00 2026-05-28T01:37:52+00:00

I have two files : index.php condition.php condition.php hold some switch statements. I wrote

  • 0

I have two files :

  • index.php
  • condition.php

condition.php hold some switch statements. I wrote only one case,but there is more than 20 cases.ow do i include the another file in index.php for showing the output..here is my code:

 //index.php    
<?
    $xml = simplexml_load_file('http://www.google.com/ig/api?weather=dhaka');
    $information = $xml->xpath("/xml_api_reply/weather/forecast_information");
    $current = $xml->xpath("/xml_api_reply/weather/current_conditions");
    $forecast_list = $xml->xpath("/xml_api_reply/weather/forecast_conditions");

    ?>
    <html>
        <head>
            <title>Google Weather API</title>
        </head>
        <body>
            <h1><?= print $information[0]->city['data']; ?></h1>
            <h2>Today's weather</h2>
            <div class="weather">       

                <?php 

                include 'condition.php';
                ?>

                <span class="condition">
                <?= $current[0]->temp_f['data'] ?>&deg; F,
                <?= $current[0]->condition['data'] ?>
                </span>

            </div>

                </body>
    </html>

here is the condition.php

 switch ($cond) 
            {
                case "Mostly Cloudy":
                    $col="/test/images/weather/mostly_cloudy.png";
                    echo "<img src=\"$col\" alt=\"\"/>";
                    break;

                case "Thunderstorm":
                    $col="/test/images/weather/thunderstorm.png";
                    echo "<img src=\"$col\" alt=\"\"/>";
                    break;}

I posted 2 cases but there is more than 20 cases.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:37:53+00:00Added an answer on May 28, 2026 at 1:37 am

    You are doing it the right way using <?php include("condition.php"); ?>, all you need to do is define $cond so the switch actually does something. Or you can create a function from condition.php and use it that way. That’s probably a “cleaner” way to work.

    Example:

    <?php
    $cond = "Thunderstorm";
    include 'condition.php';
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a scenario where I have two files, one is index.php and the
i have two files:(localhost/template/) index.php template.php each time when i create an article(an article
I have two files: index.php /lib/user.php Index contains the form: <div class=<? echo $msgclass;
So I have two files: index.php and query.php. The problem is, I don't know
The setup: I have a standard .php file (index.php) that contains two includes, one
Basically, I have two files, in two different directories: index.php (in /login/) and index.php(in
In a folder named rewrite I have two files, .htaccess and index.php <rewrite> -
I have two files (f1 and f2) containing some text (or binary data). How
Say I have two files where there is one number per line File 1
I have two php files so far, test.php: <?php include(../config_conn_fordon_db.php); include(../config_open_db.php); // Fix Special

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.