1--TEST-- 2Test compact() function : usage variations - arrays containing references. 3--FILE-- 4<?php 5/* Prototype : proto array compact(mixed var_names [, mixed ...]) 6* Description: Creates a hash containing variables and their values 7* Source code: ext/standard/array.c 8* Alias to functions: 9*/ 10/* 11* compact variations - arrays with references 12*/ 13echo "*** Testing compact() : usage variations - arrays containg references ***\n"; 14$a = 1; 15$b = 2; 16$c = 3; 17$string = "c"; 18$arr1 = array("a", &$arr1); 19$arr2 = array("a", array(array(array("b")))); 20$arr2[1][0][0][] = &$arr2; 21$arr2[1][0][0][] = &$arr2[1]; 22$arr3 = array(&$string); 23var_dump(compact($arr1)); 24var_dump(compact($arr2)); 25var_dump(compact($arr3)); 26echo "Done"; 27?> 28--EXPECTF-- 29*** Testing compact() : usage variations - arrays containg references *** 30 31Warning: compact(): recursion detected in %s on line %d 32array(1) { 33 ["a"]=> 34 int(1) 35} 36 37Warning: compact(): recursion detected in %s on line %d 38 39Warning: compact(): recursion detected in %s on line %d 40array(2) { 41 ["a"]=> 42 int(1) 43 ["b"]=> 44 int(2) 45} 46array(1) { 47 ["c"]=> 48 int(3) 49} 50Done 51