PHP Arrays
-
I’ve been using the following code to create a list of the photosets on my website. I’ll be integreating this into a WordPress page when my new site design’s finished, but in the mean time I was wondering whether anyone could give me a hand with some little bits of PHP.
<?php
$Photoset = array(
“Party 1” => “Smarch 2003”,
“Party 2” => “Smarch 2004”,
);foreach ($Photoset as $Party => $Date){
?><div class=”widetopbox”></div>
<div class=”textbox”>
<img src=”<?php bloginfo(‘stylesheet_directory’); ?>/sunthb.jpg” alt=”image” class=”alignleft” />
<div class=”setinfo”><h3><? echo $Party; ?></h3><br/>
<? echo $Date; ?>
</div>
<div class=”newset”></div>
</div>
<div class=”widebottombox”></div><?
;
}?>
All of the “widebox” stuff is just to do with the layout on my page.
At the moment the code echos that all down the page as many times are there are rows in the array. It also changes the $Party and $Date variables according to what’s in that row of the array.
My problem is that I’d like a 3rd variable. I can’t see any way of doing this with the current code, since I can only have 2 variables in the array. If anyone could tell me a way to do this using arrays or, in fact, any other method, I’d be really grateful.
- The topic ‘PHP Arrays’ is closed to new replies.