Page 2 of 2 First 12
  • Jump to page:
    #16
  1. Prom night: 1973
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Dec 2001
    Posts
    1,156
    Rep Power
    24
    My bad. I think changing the line:

    Object[] tempArr = { date, arr[1] };

    to

    Object[] tempArr = { date, arr[2] };

    will do the trick. The code I wrote was storing the date twice.
  2. #17
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    46
    Rep Power
    12
    Thanks, that seems to have worked. Thanks again for all your help.
  4. #18
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0
    I have a function that I would like to convert from php to java. The php code is below, can anyone help?


    <?php
    $tree = array('H' => 'G','F' => 'G','G' => 'D','E' => 'D','A' => 'E','B' => 'C','C' => 'E','D' => null);

    function parseTree($tree, $root = null) {
    $return = array();
    # Traverse the tree and search for direct children of the root
    foreach($tree as $child => $parent) {
    # A direct child is found
    if($parent == $root) {
    # Remove item from tree (we don't need to traverse this again)
    unset($tree[$child]);
    # Append the child into result array and parse its children
    $return[] = array(
    'name' => $child,
    'children' => parseTree($tree, $child)
    );
    }
    }
    return empty($return) ? null : $return;
    }

    function printTree($tree) {
    if(!is_null($tree) && count($tree) > 0) {
    echo '<ul>';
    foreach($tree as $node) {
    echo '<li>'.$node['name'];
    printTree($node['children']);
    echo '</li>';
    }
    echo '</ul>';
    }
    }
    $result = parseTree($tree);
    printTree($result);
    ?>
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo