mad1231999

Untitled

Jan 16th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. $categoryList = array();
  2.  
  3.     function createBlogPosts($posts) {
  4.         $np = array();
  5.  
  6.         for($i = count($posts) - 1; $i >= 0; $i--) {
  7.             $bp = new BlogPost;
  8.             $bp->read($posts[$i]);
  9.  
  10.             $hasFoundCat = False;
  11.  
  12.             foreach($categoryList as $c) {
  13.                 if($bp->category == $c) {
  14.                     $hasFoundCat = True;
  15.                     break;
  16.                 }
  17.             }
  18.  
  19.             if(!$hasFoundCat) {
  20.                 array_push($categoryList, $bp->category);
  21.             }
  22.  
  23.             array_push($np, $bp);
  24.         }
  25.  
  26.         return $np;
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment