0

i have three array and all array have relation (like:Date[0] Game[0] Data[0])

Array in index format

DATE     | GAME | DATA
17-12-14 | A    | 72
17-12-14 | B    | 16
17-12-14 | C    | 78
18-12-14 | A    | 45
18-12-14 | B    | 56
18-12-14 | C    | 89

Now i want to get result like that

DATE     | GAME | DATA
17-12-14 | C    | 78
18-12-14 | A    | 45
18-12-14 | B    | 56

Here my code what i am tried

    foreach ($date as $key => $value) {
    $dateSet=($dates[$key]);
    $gameSet=($games[$key]);
    $dataSet=($datas[$key]);

    if (($dateSet >= "17-12-14" ) &&($gameSet == "A") && ($gameSet == "B") && ($gameSet == "C")){
        echo $dateSet.'-'.$gameSet.'-'.$dataSet."<br />";
    }
    }

output A blank page :(

thank in advance

Update

    if (($dateSet >= "17-12-14" ) &&(($gameSet == "A")||($gameSet == "B")||($gameSet == "C"))){
        echo $dateSet.'-'.$gameSet.'-'.$dataSet."<br />";
    } 

now output is all six rows . but i want only 17-12-14 C row and 18-12-14 A and B rows

3
  • If you are looking for help, you would probably get more results if you asked a specific detailed question. You're on the right track just try being more verbose with your request for help Commented Dec 19, 2014 at 21:13
  • you're not comparing dates. You're comparing STRINGS. 17-12-14 is presumably Dec 17/2014, which means that 31-11-14 will test out as LARGER than 17-12-14, because 31 > 17. Commented Dec 19, 2014 at 21:16
  • @Marc B point to be noted. Commented Dec 19, 2014 at 21:35

2 Answers 2

1

You're if statement is incorrect. Change to

(($dateSet >= "17-12-14" ) && (($gameSet == "A") || ($gameSet == "B") || ($gameSet == "C")))

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

1 Comment

now output is all six rows . but i want only 17-12-14 C row and 18-12-14 A and B rows
0
if (($dateSet >= "17-12-14" ) &&($gameSet == "A") && ($gameSet == "B") && ($gameSet == "C")){

You require the variable $gameSet to be equal to A AND B AND C, which is of course impossible. You'll need to change your IF statement. Possibly by using a few OR checks ->

 if (($dateSet >= "17-12-14" ) && (($gameSet == "A") || ($gameSet == "B") || ($gameSet == "C"))){

1 Comment

now output is all six rows . but i want only 17-12-14 C row and 18-12-14 A and B rows

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.