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-- Test array_walk() function : usage variations - 'input' array with subarray --FIL..

Decoded Output download

*** Testing array_walk() : array with subarray ***

Did this file decode correctly?

Original Code

--TEST--
Test array_walk() function : usage variations - 'input' array with subarray
--FILE--
<?php
/*
 * Testing array_walk() with an array having subarrays as elements
*/

echo "*** Testing array_walk() : array with subarray ***\n";

function callback($value, $key)
{
   // dump the arguments to check that they are passed
   // with proper type
   var_dump($key);  // key
   var_dump($value); // value
   echo "\n"; // new line to separate the output between each element
}

$input = array(
  array(),
  array(1),
  array(1,2,3),
  array("Mango", "Orange"),
  array(array(1, 2, 3))
);

var_dump( array_walk( $input, "callback"));

echo "Done"
?>
--EXPECT--
*** Testing array_walk() : array with subarray ***
int(0)
array(0) {
}

int(1)
array(1) {
  [0]=>
  int(1)
}

int(2)
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}

int(3)
array(2) {
  [0]=>
  string(5) "Mango"
  [1]=>
  string(6) "Orange"
}

int(4)
array(1) {
  [0]=>
  array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(3)
  }
}

bool(true)
Done

Function Calls

array_walk 1

Variables

$input [{'key': 0, 'value': []}, {'key': 1, 'value': [{'key': 0, 'value': 1}]}, {'key': 2, 'value': [{'key': 0, 'value': 1}, {'key': 1, 'value': 2}, {'key': 2, 'value': 3}]}, {'key': 3, 'value': [{'key': 0, 'value': 'Mango'}, {'key': 1, 'value': 'Orange'}]}, {'key': 4, 'value': [{'key': 0, 'value': [{'key': 0, 'value': 1}, {'key': 1, 'value': 2}, {'key': 2, 'value': 3}]}]}]

Stats

MD5 c46ceaa8e0e19b81013e4f743e3e8db6
Eval Count 0
Decode Time 89 ms