Array help; for()/foreach() help...
Posted: Tue Jan 14, 2003 11:36 am
I have a small problem... I'm trying to select either the latest news (regular page) or all the news. heres my current script..
[code//Create bulletinsow function --bulletinshow("showallTRUE/FALSE");
function bulletinshow($all = false)
{
//create bulletins array
$bulletins = array
(
1 => bulletin("9.10.01", "-A", "For a couple months I have been promising a massive update to this site. However, after the events of September 11 (there's that date again...) I lost all inspiration to work on this site. I have now started a few personal projects that are demanding most of my time, and I'm not sure how long it will take me to get back to this site. I appreciate your visits, and I hope to return to your lives soon. Thanks!"),
2 => bulletin("19.9.02", "-Sky", "Well, well. I've modified the main page a little, i'm going to convert to a php include site layout. I might add a news ticker. I might even be able to get Sord to let me integrate into BattleSpot. as for rover sharing, i'm working on making a theme for my forums to apply to a MR category, where you'll be able to interact, etc, and able to upload/download rovers. Cheers!"),
3 => bulletin("24.12.02", "-Sky", "Bah. Haven't changed much lately, the site is now almost completely PHP. The SQL server was corrupted, so no more shouts for now. Or forums for that matter. I've been playing colobot for the last two days, and it's fun. <br /> On a side note, CMMM's Lutenint Whacker in Chaos Reigns is really cool. Battlespot has been fairly slow. That's it for now."),
4 => bulletin("13.1.03", "-Sky", "Finally got the database working again, but not for the forums. Were're changing to http://www.vxgames.net soon, so this will be http://www.mr.vxgames.net. Lata."),
);
while($current < $current3)
{
$current++;
if($all = true)
{
echo$bulletins[$current];
}
}
//shownew
if($all = false)
{
$current3 = count($bulletins);
echo $bulletins[$current3];
}
//showall
}
It doesn't cause any errors at least... not php ones, tho. I DO only want it to display the last $bulletins entry unless $all is true. Which it's not, It's just skipping along and putting all of them out there (according to zends debugger anyway)
Would someone suggest what I could do to prevent this?
[code//Create bulletinsow function --bulletinshow("showallTRUE/FALSE");
function bulletinshow($all = false)
{
//create bulletins array
$bulletins = array
(
1 => bulletin("9.10.01", "-A", "For a couple months I have been promising a massive update to this site. However, after the events of September 11 (there's that date again...) I lost all inspiration to work on this site. I have now started a few personal projects that are demanding most of my time, and I'm not sure how long it will take me to get back to this site. I appreciate your visits, and I hope to return to your lives soon. Thanks!"),
2 => bulletin("19.9.02", "-Sky", "Well, well. I've modified the main page a little, i'm going to convert to a php include site layout. I might add a news ticker. I might even be able to get Sord to let me integrate into BattleSpot. as for rover sharing, i'm working on making a theme for my forums to apply to a MR category, where you'll be able to interact, etc, and able to upload/download rovers. Cheers!"),
3 => bulletin("24.12.02", "-Sky", "Bah. Haven't changed much lately, the site is now almost completely PHP. The SQL server was corrupted, so no more shouts for now. Or forums for that matter. I've been playing colobot for the last two days, and it's fun. <br /> On a side note, CMMM's Lutenint Whacker in Chaos Reigns is really cool. Battlespot has been fairly slow. That's it for now."),
4 => bulletin("13.1.03", "-Sky", "Finally got the database working again, but not for the forums. Were're changing to http://www.vxgames.net soon, so this will be http://www.mr.vxgames.net. Lata."),
);
while($current < $current3)
{
$current++;
if($all = true)
{
echo$bulletins[$current];
}
}
//shownew
if($all = false)
{
$current3 = count($bulletins);
echo $bulletins[$current3];
}
//showall
}
It doesn't cause any errors at least... not php ones, tho. I DO only want it to display the last $bulletins entry unless $all is true. Which it's not, It's just skipping along and putting all of them out there (according to zends debugger anyway)
Would someone suggest what I could do to prevent this?