Guest User

Untitled

a guest
Jul 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.83 KB | None | 0 0
  1.      function get_nested_projects($Projects, $ParentID = 0, $indent='')
  2.      {
  3.             $Ret = array();
  4.             foreach($Projects as $Project)
  5.             {
  6.         echo '<pre>';print_r($Project);echo '<pre>';
  7.      
  8.         if(!isset($Project->parent_id))
  9.         {
  10.           echo 'project parent id';
  11.         }
  12.  
  13.             }
  14.      }
  15.  
  16. Output:
  17.  
  18. Array
  19. (
  20.     [0] => stdClass Object
  21.         (
  22.             [p_id] => 1
  23.             [c_id] => 1
  24.             [project_name] => Root Project
  25.             [project_desc] => Root Project
  26.             [date_added] => 2012-01-01 00:00:00
  27.             [parent_id] => 0
  28.             [allocated_hrs] => 100
  29.             [date_from] => 2012-01-01 00:00:00
  30.             [date_to] => 2012-01-01 00:00:00
  31.             [status] => active
  32.             [priority] => 1
  33.             [completed] => 1
  34.             [author] => 1
  35.             [p_date_added] => 1st Jan 2012
  36.             [date_from_formatted] => 2012-01-01
  37.             [date_to_formatted] => 2012-01-01
  38.             [proj_id] => 1
  39.             [cust_name] => Root Customer
  40.             [cust_id] => 1
  41.             [parent_name] =>
  42.         )
  43.  
  44.     [1] => stdClass Object
  45.         (
  46.             [p_id] => 120
  47.             [c_id] => 2
  48.             [project_name] => Another project
  49.             [project_desc] => another project
  50.             [date_added] => 2012-01-01 00:00:00
  51.             [parent_id] => 2
  52.             [allocated_hrs] => 100
  53.             [date_from] => 2012-01-01 00:00:00
  54.             [date_to] => 2012-01-01 00:00:00
  55.             [status] => active
  56.             [priority] => 1
  57.             [completed] => 1
  58.             [author] => 271
  59.             [p_date_added] => 1st Jan 2012
  60.             [date_from_formatted] => 2012-01-01
  61.             [date_to_formatted] => 2012-01-01
  62.             [proj_id] => 120
  63.             [cust_name] => Customer 2
  64.             [cust_id] => 2
  65.             [parent_name] => Mini project
  66.         )
  67.  
  68.     [2] => stdClass Object
  69.         (
  70.             [p_id] => 3
  71.             [c_id] => 2
  72.             [project_name] => This is a project
  73.             [project_desc] => This is a projectThis is a projectThis is a projectThis is a projectThis is a projectThis is a projectThis is a projectThis is a projectThis is a project
  74.             [date_added] => 2012-03-28 09:27:16
  75.             [parent_id] => 1
  76.             [allocated_hrs] => 100
  77.             [date_from] => 2012-10-10 00:00:00
  78.             [date_to] => 2012-11-10 00:00:00
  79.             [status] => active
  80.             [priority] => 1
  81.             [completed] => 0
  82.             [author] => 271
  83.             [p_date_added] => 28th Mar 2012
  84.             [date_from_formatted] => 2012-10-10
  85.             [date_to_formatted] => 2012-11-10
  86.             [proj_id] => 3
  87.             [cust_name] => Customer 2
  88.             [cust_id] => 2
  89.             [parent_name] => Root Project
  90.         )
  91.  
  92. )
  93.  
  94. project parent id
Add Comment
Please, Sign In to add comment