Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.