Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- SPL: RecursiveIteratorIterator and setMaxDepth() --FILE-- <?php $ar = array(1, 2..

Decoded Output download

--TEST--
SPL: RecursiveIteratorIterator and setMaxDepth()
--FILE--
<?php

$ar = array(1, 2, array(31, 32, array(331, array(3321, array(33221)))), 4);

$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($ar));

echo "===?===
";
var_dump($it->getMaxDepth());
foreach($it as $v) echo $it->getDepth() . ": $v
";

echo "===2===
";
$it->setMaxDepth(2);
var_dump($it->getMaxDepth());
foreach($it as $v) echo $it->getDepth() . ": $v
";

echo "===X===
";
$it->setMaxDepth();
var_dump($it->getMaxDepth());
foreach($it as $v) echo $it->getDepth() . ": $v
";

echo "===3===
";
$it->setMaxDepth(3);
var_dump($it->getMaxDepth());
foreach($it as $v) echo $it->getDepth() . ": $v
";

echo "===5===
";
$it->setMaxDepth(5);
var_dump($it->getMaxDepth());
foreach($it as $v) echo $it->getDepth() . ": $v
";

echo "===0===
";
$it->setMaxDepth(0);
var_dump($it->getMaxDepth());
foreach($it as $v) echo $it->getDepth() . ": $v
";

echo "===-1===
";
$it->setMaxDepth(-1);
var_dump($it->getMaxDepth());
$it->setMaxDepth(4);
try {
    $it->setMaxDepth(-2);
} catch(\ValueError $e) {
    echo $e->getMessage() . \PHP_EOL;
}
var_dump($it->getMaxDepth());
?>
--EXPECT--
===?===
bool(false)
0: 1
0: 2
1: 31
1: 32
2: 331
3: 3321
4: 33221
0: 4
===2===
int(2)
0: 1
0: 2
1: 31
1: 32
2: 331
0: 4
===X===
bool(false)
0: 1
0: 2
1: 31
1: 32
2: 331
3: 3321
4: 33221
0: 4
===3===
int(3)
0: 1
0: 2
1: 31
1: 32
2: 331
3: 3321
0: 4
===5===
int(5)
0: 1
0: 2
1: 31
1: 32
2: 331
3: 3321
4: 33221
0: 4
===0===
int(0)
0: 1
0: 2
0: 4
===-1===
bool(false)
RecursiveIteratorIterator::setMaxDepth(): Argument #1 ($maxDepth) must be greater than or equal to -1
int(4)

Did this file decode correctly?

Original Code

--TEST--
SPL: RecursiveIteratorIterator and setMaxDepth()
--FILE--
<?php

$ar = array(1, 2, array(31, 32, array(331, array(3321, array(33221)))), 4);

$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($ar));

echo "===?===\n";
var_dump($it->getMaxDepth());
foreach($it as $v) echo $it->getDepth() . ": $v\n";

echo "===2===\n";
$it->setMaxDepth(2);
var_dump($it->getMaxDepth());
foreach($it as $v) echo $it->getDepth() . ": $v\n";

echo "===X===\n";
$it->setMaxDepth();
var_dump($it->getMaxDepth());
foreach($it as $v) echo $it->getDepth() . ": $v\n";

echo "===3===\n";
$it->setMaxDepth(3);
var_dump($it->getMaxDepth());
foreach($it as $v) echo $it->getDepth() . ": $v\n";

echo "===5===\n";
$it->setMaxDepth(5);
var_dump($it->getMaxDepth());
foreach($it as $v) echo $it->getDepth() . ": $v\n";

echo "===0===\n";
$it->setMaxDepth(0);
var_dump($it->getMaxDepth());
foreach($it as $v) echo $it->getDepth() . ": $v\n";

echo "===-1===\n";
$it->setMaxDepth(-1);
var_dump($it->getMaxDepth());
$it->setMaxDepth(4);
try {
    $it->setMaxDepth(-2);
} catch(\ValueError $e) {
    echo $e->getMessage() . \PHP_EOL;
}
var_dump($it->getMaxDepth());
?>
--EXPECT--
===?===
bool(false)
0: 1
0: 2
1: 31
1: 32
2: 331
3: 3321
4: 33221
0: 4
===2===
int(2)
0: 1
0: 2
1: 31
1: 32
2: 331
0: 4
===X===
bool(false)
0: 1
0: 2
1: 31
1: 32
2: 331
3: 3321
4: 33221
0: 4
===3===
int(3)
0: 1
0: 2
1: 31
1: 32
2: 331
3: 3321
0: 4
===5===
int(5)
0: 1
0: 2
1: 31
1: 32
2: 331
3: 3321
4: 33221
0: 4
===0===
int(0)
0: 1
0: 2
0: 4
===-1===
bool(false)
RecursiveIteratorIterator::setMaxDepth(): Argument #1 ($maxDepth) must be greater than or equal to -1
int(4)

Function Calls

None

Variables

$ar [{'key': 0, 'value': 1}, {'key': 1, 'value': 2}, {'key': 2, 'value': [{'key': 0, 'value': 31}, {'key': 1, 'value': 32}, {'key': 2, 'value': [{'key': 0, 'value': 331}, {'key': 1, 'value': [{'key': 0, 'value': 3321}, {'key': 1, 'value': [{'key': 0, 'value': 33221}]}]}]}]}, {'key': 3, 'value': 4}]

Stats

MD5 b906bfb1164b54d304ca005b7f9257dd
Eval Count 0
Decode Time 129 ms