0

I'm trying to build a PHP if expression.

In English, here's the conditions for the IF to be true:

Visbility < 5000m

OR

BKN/OVC < 1500ft

Now, the variables I have to play with are:

for Visibility: $visibility and for the BKN/OVC: it's a bit more complex.

This data is given in

$xml->data->METAR[0]->sky_condition

The data itself is pulled from XML file with the relevant information looking like this:

<sky_condition sky_cover="BKN" cloud_base_ft_agl="600"/>
<sky_condition sky_cover="SCT" cloud_base_ft_agl="1100"/>

Any ideas on how I could sort through the sky_condition->sky_cover for the relevant information and feed it through to the IF?

Thanks.

2
  • 1
    What is the difference with this other question you asked? Commented Aug 24, 2012 at 22:31
  • This specifically deals with one element in deciding whether one variable is true or not, based on information from the XML. The other question was basically outputting the data from the XML. Commented Aug 24, 2012 at 22:32

1 Answer 1

1

You could access the attributes of the XML with the array syntax instead of the arrow operator.

if((string)$xml->data->METAR[0]->sky_condition[0]['sky_cover']==='???') {

}

Was this your question?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.