Welcome Guest, Not a member yet? Register   Sign In
Why can't I limit this Array
#1

[eluser]RaZoR LeGaCy[/eluser]
I am having problems limiting this array. I tried array_slice and it didn't work.

Code:
$channel = Array ( [items] => Array ( [0] => Array ( [title] => 'Horror frog' breaks own bones to produce claws [link] => http://digg.com/general_sciences/Horror_frog_breaks_own_bones_to_produce_claws_3 [description] => Actively breaks its own bones to produce claws that puncture their way out of the frog's toe pads, probably when it is threatened. [pubDate] => Thu, 29 May 2008 10:57:24 +0000 ) [1] => Array ( [title] => The 7 Most Annoying People On Digg [link] => http://digg.com/comedy/The_7_Most_Annoying_People_On_Digg [description] => Despite being arguably the most mainstream site of its kind, digg.com still is not free of the countless horrors that spawn in the seedy underbelly of the net. Today, we take you on a virtual safari to show you some of the worst species in the digg community. [pubDate] => Fri, 23 May 2008 00:53:50 +0000 ) )

I want to limit that and my current code is
Code:
if(is_array($channel)) {
    foreach ($channel as $item) {
    
        foreach ($item as $row) {
        
            echo $row['title'] ."<br />\n";
        }
    }
}
else {
    break;
}

Thanks everyone.
#2

[eluser]gtech[/eluser]
Code:
&lt;?php
class Temp extends Controller {

  function Temp()
  {
    parent::Controller();
  }
  function index()
  {
    $channel = Array ( 'items'=> Array (
      0=> Array (
        'title'       => "'Horror frog' breaks own bones to produce claws",
        'link'        => "http://digg.com/general_sciences/Horror_frog_breaks_own_bones_to_produce_claws_3",
        'description' => "Actively breaks its own bones to produce claws that puncture their way out of the frog's toe pads, probably when it is threatened.",
        'pubDate'     => "Thu, 29 May 2008 10:57:24 +0000"
      ),
      1 => Array (
        'title' => "The 7 Most Annoying People On Digg",
        'link' => "http://digg.com/comedy/The_7_Most_Annoying_People_On_Digg",
        'description' => "Despite being arguably the most mainstream site of its kind, digg.com still is not free of the countless horrors that spawn in the seedy underbelly of the net. Today, we take you on a virtual safari to show you some of the worst species in the digg community.",
        'pubDate'     => "Fri, 23 May 2008 00:53:50 +0000" )
      )
    );

    print_r(array_slice($channel['items'], 1));
    echo "<br>";
    echo "<br>";

    if(is_array($channel)) {
      foreach ($channel as $item) {
        foreach ($item as $row) {
          echo $row['title'] ."<br />\n";
        }
      }
    }
  }
}
?&gt;
ok I ran the above code, and the result when I run the code is

Code:
Array ( [0] => Array ( [title] => The 7 Most Annoying People On Digg [link] => http://digg.com/comedy/The_7_Most_Annoying_People_On_Digg [description] => Despite being arguably the most mainstream site of its kind, digg.com still is not free of the countless horrors that spawn in the seedy underbelly of the net. Today, we take you on a virtual safari to show you some of the worst species in the digg community. [pubDate] => Fri, 23 May 2008 00:53:50 +0000 ) )


'Horror frog' breaks own bones to produce claws
The 7 Most Annoying People On Digg

I dont understand what you are trying to output and what you are trying to limit?




Theme © iAndrew 2016 - Forum software by © MyBB