Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "flow":[
- {
- "tasks":[
- { "id":"1", "uid":"bryan" },
- { "id":"2", "uid":"eric" }
- ]
- },
- {
- "tasks":[
- { "id":"1", "uid":"bryan" },
- { "id":"2", "uid":"eric" }
- ]
- },
- {
- "tasks":[
- { "id":"1", "uid":"bryan" },
- { "id":"2", "uid":"eric" }
- ]
- },
- {
- "tasks":[
- { "id":"1", "uid":"bryan" },
- { "id":"2", "uid":"eric" },
- { "id":"3", "uid":"eric" },
- { "id":"4", "uid":"bryan" }
- ]
- }
- ]
- }
- {
- "flow":[
- {
- "tasks":[
- { "id":"2", "uid":"eric" },
- { "id":"1", "uid":"bryan" }
- ]
- },
- {
- "tasks":[
- { "id":"2", "uid":"eric" },
- { "id":"1", "uid":"bryan" }
- ]
- },
- {
- "tasks":[
- { "id":"2", "uid":"eric" },
- { "id":"1", "uid":"bryan" }
- ]
- },
- {
- "tasks":[
- { "id":"2", "uid":"eric" },
- { "id":"3", "uid":"eric" },
- { "id":"1", "uid":"bryan" },
- { "id":"4", "uid":"bryan" }
- ]
- }
- ]
- }
- function reorder_flow($flow, $uid)
- {
- foreach($flow as &$step)
- {
- //step is the array with tasks
- $tasks = $step['tasks'];
- $new_tasks = array();
- foreach($tasks as $key => $t)
- {
- if($t['uid'] == $uid)
- {
- $new_tasks = $new_tasks + $t;
- unset($tasks[$key]);
- }
- }
- $step['tasks'] = $new_tasks + $step['tasks'];
- }
- return $flow;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement