Page 1 of 1

Foreach loop with the array of a public function

Posted: Thu Apr 10, 2008 1:53 pm
by mofle
Hi, i need to do a loop of the array of this function found in the WebUI API:

Code: Select all

public function getTorrents()

WebUI API: http://pastebin.com/m76205d0b


I have this one, but it doesn't work.

Code: Select all

$utorrent = new uTorrent();
$utorrent->host = $_SESSION['host'];
$utorrent->user = $_SESSION["user"];
$utorrent->pass = $_SESSION["pass"];
$torrents = $utorrent->getTorrents();
 
foreach($torrents as $torrent) {
    echo $torrent[UTORRENT_TORRENT_NAME]."\n";
}
How do i use the "public function getTorrents()" to get the array into a foreach loop?

I really appreciate your help ;)

Re: Foreach loop with the array of a public function

Posted: Thu Apr 10, 2008 3:26 pm
by RobertGonzalez
Try looking at the return of that method using var_dump(). See what is coming from it.

Re: Foreach loop with the array of a public function

Posted: Sat Apr 12, 2008 5:01 am
by mofle
I've tried using the var_dump(), the result was:
NULL Array

Re: Foreach loop with the array of a public function

Posted: Sat Apr 12, 2008 5:26 pm
by RobertGonzalez
There is something that is not being set properly. You may need to inspect each variable for each step of the code.