Page 1 of 1

Multidimensional Array

Posted: Sat Apr 05, 2008 2:34 pm
by mofle
I use Yahoo Pipes to get some content using the a serialized PHP:

Code: Select all

$request =  "http://pipes.yahoo.com/pipes/pipe.run?_id=DsfnOGlK3BGw4DuRJZhxuA&_render=php&search=alias";
 
$response = file_get_contents($request);
 
if ($response === false) {
    die('Request failed');
}
 
$phpobj = unserialize($response);
 
I have a variable ($search) with the results from a form.
And the url should be something like this:
http://pipes.yahoo.com/pipes/pipe.run?_ ... ch=$search


The array I get from Pipes is a Multidimensional Array, like this:
http://pastebin.com/m2a6649b4


What i need is a loop for the "title" and the "link".

With the "link" as a href to the the title.

And I need to change the link from:
http://www.mininova.org/get/1290875
to
http://" . $_SESSION["user"] . $_SESSION["pass"] . $_SESSION['host'] . "/gui/?action=get-url&s=" . urlencode(http://www.mininova.org/get/1290875)

For example:
http://username:password@192.168.0.1:99 ... %2F1290875


I really hope someone can help me with this one ;)

Re: Multidimensional Array

Posted: Sat Apr 05, 2008 9:35 pm
by John Cartwright

Code: Select all

$foobar = unserialize($response);
foreach ($foobar['value']['items'] as $row) {
   echo '<a href="http://' . $_SESSION["user"] . $_SESSION["pass"] . $_SESSION['host'] . '/gui/?action=get-url&s=' . urlencode($row["link"]).'">'. $row["title"].'</a>'; 
}
 
I would suggest you take a look at arrays, and foreach loops