Wanna use if for array elements :s

Discussion in 'PHP' started by khan11, Oct 2, 2007.

  1. #1
    Hi guys!


    I wanna do something like this:

    I have displayed my array elements in descending order like this:

    element 10
    element 9
    ....

    I want to use if statements for them because i want to assign each element a specific date, like this:
    if($date < 0510) { echo "my element a" } else {echo "This element is expired"}


    i want to use this thing inside an array for each element individually..


    any solution or ideas....?
     
    khan11, Oct 2, 2007 IP
  2. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    foreach ($datearray as $date) {
             if ($date < 100) {
                      echo 'blah';
             }
    }
    
    PHP:
     
    matthewrobertbell, Oct 2, 2007 IP
  3. khan11

    khan11 Active Member

    Messages:
    615
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    58
    #3
    thanks but this applies for all array elements, i want to apply if individually..

    like if $date=1912 it will show element a, element b will be shown on its own place
     
    khan11, Oct 2, 2007 IP