Files
vscode-debug-visualizer/demo/php/demo.php
Henning Dieterichs 218f670528 Improves php demo.
2020-02-22 13:40:24 +01:00

29 lines
574 B
PHP

<?php
$graph = [
"kind" => ["graph" => true],
"nodes" => [
["id" => "1", "label" => "1"]
],
"edges" => []
];
// Visualize "$visualize()"
$visualize = function () use (&$graph) {
return json_encode($graph);
};
for ($i = 2; $i < 100; $i++) {
// add a node
$id = "" . $i;
array_push($graph["nodes"], ["id" => $id, "label" => $id]);
// connects the node to a random edge
$targetId = "" . random_int(1, $i - 1);
array_push($graph["edges"], ["from" => $id, "to" => "" . $targetId]);
xdebug_break();
}
echo "finished";