Jump to content

simplification


levidyllan

Recommended Posts

hi!  I have the following two arrays and then what I put in them, just wondering if there is a better way ?

The arrays

$dec =array();	
$deca =array();	

 

then adding to the arrays:

 

 if($row['events_month']=="December"){
      $dec[]=$row['events_title'];
  $deca[]=$row['events_id'];
      }// end if

 

so could I create a double array and have it enter the info into this reducing the need for two arrays, something like:


$dec=array();

if($row['events_month']=="December"){
      $dec[]=($row['events_title'], $row['events_id']);
      }// end if

So it could be called like "echo 'title: ' .$dec[1,0] . ' code: ' . $dec[1,0];

etc etc

 

this is how I display it at the moment.

if ($decCount > 0){
?>
<h2><span class="monlink"><a href="events.php?month=December" onclick="document.getElementById('decDiv').style.display = ''; return false;">December </a></span><span class="entries">(<?php echo $decCount ?>)</span></h2>
<?php
	echo'<div id="decDiv" style="display:none;">';
		for($i=0; $i<=$decCount; $i++){
	echo '<h3><a href="events.php?event='.$deca[$i].'&month=Decemeber">' . $dec[$i] . '</a></h3>';
}
	echo '</div>';

}

 

 

Link to comment
https://forums.phpfreaks.com/topic/56238-simplification/
Share on other sites

but how would I combine this into my code where at the mo i would have :

 

$jan[] = array($row['events_title'], $row['events_id']);

$feb[] = array($row['events_title'], $row['events_id']);

$mar[] = array($row['events_title'], $row['events_id']);

...etc etc

 

so how would I display this version then:

 

simply put "echo $dec[1]['month'];" etc

Link to comment
https://forums.phpfreaks.com/topic/56238-simplification/#findComment-277826
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.