<?php
function dijkstra($graph_array, $source, $target) {
    $vertices = array();
    $neighbours = array();
    foreach ($graph_array as $edge) {
        array_push($vertices, $edge[0], $edge[1]);
        $neighbours[$edge[0]][] = array( => $edge[1],  => $edge[2]);
        $neighbours[$edge[1]][] = array( => $edge[0],  => $edge[2]);
    }
    $vertices = array_unique($vertices);

    foreach ($vertices as $vertex) {
        $dist[$vertex] = INF;
        $previous[$vertex] = NULL;
    }

    $dist[$source] = 0;
    $Q = $vertices;
    while (count($Q) > 0) {

        
        $min = INF;
        foreach ($Q as $vertex){
            if ($dist[$vertex] < $min) {
                $min = $dist[$vertex];
                $u = $vertex;
            }
        }

        $Q = array_diff($Q, array($u));
        if ($dist[$u] == INF or $u == $target) {
            break;
        }

        if (isset($neighbours[$u])) {
            foreach ($neighbours[$u] as $arr) {
                $alt = $dist[$u] + $arr[];
                if ($alt < $dist[$arr[]]) {
                    $dist[$arr[]] = $alt;
                    $previous[$arr[]] = $u;
                }
            }
        }
    }
    $path = array();
    $u = $target;
    while (isset($previous[$u])) {
        array_unshift($path, $u);
        $u = $previous[$u];
    }
    array_unshift($path, $u);
    return $path;
}

$graph_array = array(
                    array(, , 7),
                    array(, , 9),
                    array(, , 14),
                    array(, , 10),
                    array(, , 15),
                    array(, , 11),
                    array(, , 2),
                    array(, , 6),
                    array(, , 9)
               );

$path = dijkstra($graph_array, , );

echo .implode(, $path).;