Comparing the data

Asked

Viewed 63 times

0

I would like to know how to compare several elements, in this example I have only four. But in the listing I have more than 40. If I were to make one by one, the code would be incomprehensible and liable to major errors... Can anyone help me how to make a comparison with several variables? I appreciate your help!

$result1 = $result['linha'][0]['elemento'][0]['tempo']['text'];
$result2 = $result['linha'][0]['elemento'][1]['tempo']['text'];
$result3 = $result['linha'][0]['elemento'][2]['tempo']['text'];
$result4 = $result['linha'][0]['elemento'][3]['tempo']['text'];

$endereço1 = "rua alves fiho";

if ($result1 < $result2) {
    $result1 = $endereço1;
}
  • In the title you talk in comparison, then you talk in ordering, then you talk about making code manually, things that are different. It would be nice for you to click on [Dit] and complement your post by explaining better exactly what your question is (what the problem you’re actually having, and not just how you’re trying to solve it), so we can help.

1 answer

0

To sort arrays you can use the function Sort()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.