Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("systems.php");
- $History = array();
- function moveOrigin($nextID, $targetID, $history, $depth){
- global $Systems;
- //NextID is the key for the next steps to be made off of.
- $potentials = $Systems[$nextID]["JumpsTo"];
- if(!empty($potentials)){
- if(!in_array($targetID, $potentials)){ //Not at end location, therefore try next location
- array_push($history, $nextID);
- $depth++;
- if($depth < 9){
- foreach($potentials as $value){
- if(!in_array($value, $history)){
- if(isset(moveOrigin($value, $targetID, $history, $depth) = $output)){
- return $output;
- }
- }
- }
- }else{
- return;
- }
- }
- foreach($history as $systemID){
- $output .= "{$Systems[$SystemID]["Name"]} ({$Systems[$SystemID]["Sec"]})<br>\n";
- }
- $output .= "{$Systems[$targetID]["Name"]} ({$Systems[$targetID]["Sec"]})<br>\n";
- return $output;
- }
- }
- $origin = 30000142; //Get starting point
- $target = 30000001; //Get end point
- moveOrigin($origin, $target, array(), 0);
- array_push($History, $target);
- $from = $Systems[$History[0]]["Name"];
- $to = $Systems[$History[Count($History) - 1]]["Name"];
- echo "From: $from, To: $to -><br>";
- foreach($History as $SystemID){
- echo "{$Systems[$SystemID]["Name"]} ({$Systems[$SystemID]["Sec"]})<br>";
- };
- ?>
Advertisement
Add Comment
Please, Sign In to add comment