Before I go into detail with the big question, my itching one is this: how do you call the last instance of a foreach loop? Now, the foreach is meant to be a loop for the physical size of the array, not the actual size. So I have a script that posts the first 5 topics of a forum, but if there aren't enough, it posts as many as it can, with the foreach loop. I want to add a copyright statement to the last topic, is there anyway to do this? Like:
foreach($topics as $topic)
...
if(isLast($topic))
echo($blah)
Is that at all possible?
Now for the real question...what is the scope of $_GET?
To understand what I mean, let me post code.
Index.php:
<?php
$page = $_GET["page"];
if(!file_exists('content/'.$page.'.php') || $page == null)
include("content/news.php");
else
include("content/".$page.".php");
?>
This works fine and dandy, no complaints. However, my news.php also needs to be about to $_GET a variable, to know which news item to post (if specified).
So I have the code written as so in my news.php file:
<?php
$id = $GET_["id"];
$topics = $SDK->list_forum_topics ("2", array("limit" => "1", "start" => "0", "order" => "desc", "orderby" => "post_date"), "1");
if(!$id || $id == null)
$topic = $topics[0];
else
$topic = $SDK->get_topic_info($id);
?>
This is supposed to get the $id variable, and assign $topic to it, but if there is none, or it's null, it takes the newest topic from the forum to post (which would be the newest news item). However, I've debugged this so many times, and it never prints out a $id. The links I use are /?id='$id' and I've also tried using /page=news&id='$id'. It just seems like it won't retrieve the $id file from the browser. How can I fix this?
Edit: It's nothing to do with the $SDK class either. I tried a flat number for the last line '$topic = $SDK->get_topic_info(4);' and it worked perfectly. The problem deals with retrieving $id from the browser.