PHP library to detect reference circular references in array.
Open a command console, enter your project directory and execute the following command to download the latest stable version of this library:
$ composer require antalaron/circular-reference-detect
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Find a circular reference in an array:
require __DIR__.'/vendor/autoload.php';
use Antalaron\Component\CircularReferenceDetect\CircularReferenceDetect;
$a = [
'a' => ['b'],
'b' => ['c'],
'c' => ['a'],
];
$detector = new CircularReferenceDetect();
$detector->hasCircularReference($a);
This library is under MIT License.