Page 1 of 1

Array question

Posted: Sat Oct 25, 2008 5:20 am
by Addos
Hi,
Looking for some help on this as I need to pass $heading_dates = array('2009','2010'); to
if($date = substr($date, -4) == $heading_dates[0]) but I’m not sure how to get the $heading_dates[] to return $heading_dates[0] and $heading_dates[1] to if($date = substr($date, -4)

I think I might need a loop to return the index from the array but I’m not really sure. I know I could simply write out the code twice to pass the '2009','2010' dates to each but I’m really wanting to get the hang of using less code even if this is not a big chunk of script.
Thanks for any help


Code: Select all

// Look for future dates beyond present one   
           do {
        $heading_dates = array('2009','2010');
        
         $date = $row_GetEngag['heading'];
  if($date = substr($date, -4) == $heading_dates[????]) {
                
    echo "<br><h1>Future Engagements</h1> ";
 
     ?>
        <a href=" results.php?id=<?php echo $row_GetEngag['engage_id']; ?>">                     <?php echo $row_GetEngag['heading']; ?></a><br />
    <?PHP } ?>    
       <?php } while ($row_GetEngag = mysql_fetch_assoc($GetEngag)); ?>

Re: Array question

Posted: Sat Oct 25, 2008 7:34 am
by Hannes2k
Hi,
why do you don't use the in_array() function?