Multidimensional Array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mofle
Forum Newbie
Posts: 6
Joined: Fri Apr 06, 2007 10:02 pm

Multidimensional Array

Post 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 ;)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Multidimensional Array

Post 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
Post Reply