My example was not totally accurate.
I don't want to publish specifics of the project, so let me explain it in a little different way:
I have a node with standard parameters (options that will be changed via a form).
$node = array(param1, param2, param3...);
Then there is a hierarchical structure, like a tree where those nodes saved with different values. As you see, the node array keys are the same, only the values are different. The hierarchy is very important as it's being used to store nodes in a certain parent/child order and then output in that specific way.
The form, is just a mechanism of changing those node values.
So, here is example of the array:
Code: Select all
$tree = array(
node1 => array(
param1 => a,
param2 => b,
param3 => c,
child => array(
node_1 => array (
param1 => e,
param2 => r,
param3 => t,
child => array(
node_2 => array (
param1 => 1,
param2 => 2,
param3 => 3,
child =>
),
),
),
node2 => array(
param1 => h,
param2 => j,
param3 => k,
child =>
);
);
The number and depth of nodes and their children is unlimited. As you can see some nodes can have no children at all. But the hierarchy is very important.
I'm totally new to classes and objects. I've used them before, but not in an extensive way. I have a class that turns the whole $tree into an object and every single node as well. Since the $_POST['node_name'] is the key of the actual node, I thought I might be able to have an "update" method in a class, that searches for the node key and updates its parameters to the $_POST['node_name']. I could not get the same thing to work in a regular recursive search function, but I think in a class, inside of a recursive update method by using $this->node it might actually work. I'm not sure.
Another important feature I need to implement - I need to be able to move nodes within the tree structure. Kind of like from sub folders into an upper level folder or a completely different folder within the same tree.
I hope this is more clear explanation of my dilemma
