PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Christian   Anti_Util_CircularReference   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example usage
Class: Anti_Util_CircularReference
Find circular references using waypoint array
Author: By
Last change:
Date: 15 years ago
Size: 958 bytes
 

Contents

Class file image Download
$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>";
}
?>