Location: PHPKode > scripts > Anti_Util_CircularReference > anti_util_circularreference/example.php
$waypoints = array(
    "a" => array(1,2),
    "b" => array(2,3),
    "c" => array(2,4),
    "d" => array(4,5),
    "e" => array(5,9),
    "f" => array(6,7),
    "g" => array(7,8),
    "h" => array(7,9),
    "i" => array(9,10),
    "j" => array(10,11),
    "k" => array(11,12),
    "l" => array(10,13),
    "m" => array(13,14),
    "n" => array(12,10),
    "o" => array(12,15),
    "p" => array(15,16));
// circular reference is j(10,11), k(11,12), n(12,10)
// waypoint keys (a, b, ..) are optional
try {
    Anti_Util_CircularReference::checkArray($waypoints);
    echo "no circular reference found";
} catch (Anti_Util_CircularReference_Exception $exception) {
    echo $exception->getMessage(),
        "<hr />",
        "<pre>",
        print_r($exception->getWaypointTrace(), true),
        "</pre>",
        "<hr />",
        "<pre>",
        print_r($exception->getCausingWaypointTrace(), true),
        "</pre>";
}
?>
Return current item: Anti_Util_CircularReference