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 join() function : usage variations - different values for 'pieces' argument ..

Decoded Output download

*** Testing join() : usage variations ***
-- Iteration 1 --

Did this file decode correctly?

Original Code

--TEST--
Test join() function : usage variations - different values for 'pieces' argument
--FILE--
<?php
/*
 * test join() by giving different pieces values
*/

echo "*** Testing join() : usage variations ***\n";

$pieces_arrays = array (
  array(1, 2), // array with default keys and numrice values
  array(1.1, 2.2), // array with default keys & float values
  array( array(2), array(1)), // sub arrays
  array(false,true), // array with default keys and boolean values
  array(), // empty array
  array(NULL), // array with NULL
  array("a","aaaa","b","bbbb","c","ccccc"),

  // associative arrays
  array(1 => "one", 2 => "two", 3 => "three"),  // explicit numeric keys, string values
  array("one" => 1, "two" => 2, "three" => 3 ),  // string keys & numeric values
  array( 1 => 10, 2 => 20, 4 => 40, 3 => 30),  // explicit numeric keys and numeric values
  array( "one" => "ten", "two" => "twenty", "three" => "thirty"),  // string key/value
  array("one" => 1, 2 => "two", 4 => "four"),  //mixed

  // associative array, containing null/empty/boolean values as key/value
  array(NULL => "NULL", null => "null", "NULL" => NULL, "null" => null),
  array(true => "true", false => "false", "false" => false, "true" => true),
  array("" => "emptyd", '' => 'emptys', "emptyd" => "", 'emptys' => ''),
  array(1 => '', 2 => "", 3 => NULL, 4 => null, 5 => false, 6 => true),
  array('' => 1, "" => 2, NULL => 3, null => 4, false => 5, true => 6),

  // array with repetitive keys
  array("One" => 1, "two" => 2, "One" => 10, "two" => 20, "three" => 3)
);

// a multichar glue value
$glue = "], [";

// loop through each $pieces_arrays element and call join()
$iteration = 1;
for($index = 0; $index < count($pieces_arrays); $index ++) {
  echo "-- Iteration $iteration --\n";
  var_dump( join($glue, $pieces_arrays[$index]) );
  $iteration ++;
}

echo "Done\n";
?>
--EXPECTF--
*** Testing join() : usage variations ***
-- Iteration 1 --
string(6) "1], [2"
-- Iteration 2 --
string(10) "1.1], [2.2"
-- Iteration 3 --

Warning: Array to string conversion in %s on line %d

Warning: Array to string conversion in %s on line %d
string(14) "Array], [Array"
-- Iteration 4 --
string(5) "], [1"
-- Iteration 5 --
string(0) ""
-- Iteration 6 --
string(0) ""
-- Iteration 7 --
string(36) "a], [aaaa], [b], [bbbb], [c], [ccccc"
-- Iteration 8 --
string(19) "one], [two], [three"
-- Iteration 9 --
string(11) "1], [2], [3"
-- Iteration 10 --
string(20) "10], [20], [40], [30"
-- Iteration 11 --
string(23) "ten], [twenty], [thirty"
-- Iteration 12 --
string(16) "1], [two], [four"
-- Iteration 13 --
string(12) "null], [], ["
-- Iteration 14 --
string(22) "true], [false], [], [1"
-- Iteration 15 --
string(14) "emptys], [], ["
-- Iteration 16 --
string(21) "], [], [], [], [], [1"
-- Iteration 17 --
string(11) "4], [5], [6"
-- Iteration 18 --
string(13) "10], [20], [3"
Done

Function Calls

join 1
count 1

Variables

$glue ], [
$index 0
$iteration 1
$pieces_arrays [{'key': 0, 'value': [{'key': 0, 'value': 1}, {'key': 1, 'value': 2}]}, {'key': 1, 'value': [{'key': 0, 'value': 1.1}, {'key': 1, 'value': 2.2}]}, {'key': 2, 'value': [{'key': 0, 'value': [{'key': 0, 'value': 2}]}, {'key': 1, 'value': [{'key': 0, 'value': 1}]}]}, {'key': 3, 'value': [{'key': 0, 'value': False}, {'key': 1, 'value': True}]}, {'key': 4, 'value': []}, {'key': 5, 'value': [{'key': 0, 'value': 0}]}, {'key': 6, 'value': [{'key': 0, 'value': 'a'}, {'key': 1, 'value': 'aaaa'}, {'key': 2, 'value': 'b'}, {'key': 3, 'value': 'bbbb'}, {'key': 4, 'value': 'c'}, {'key': 5, 'value': 'ccccc'}]}, {'key': 7, 'value': [{'key': 1, 'value': 'one'}, {'key': 2, 'value': 'two'}, {'key': 3, 'value': 'three'}]}, {'key': 8, 'value': [{'key': 'one', 'value': 1}, {'key': 'two', 'value': 2}, {'key': 'three', 'value': 3}]}, {'key': 9, 'value': [{'key': 1, 'value': 10}, {'key': 2, 'value': 20}, {'key': 4, 'value': 40}, {'key': 3, 'value': 30}]}, {'key': 10, 'value': [{'key': 'one', 'value': 'ten'}, {'key': 'two', 'value': 'twenty'}, {'key': 'three', 'value': 'thirty'}]}, {'key': 11, 'value': [{'key': 'one', 'value': 1}, {'key': 2, 'value': 'two'}, {'key': 4, 'value': 'four'}]}, {'key': 12, 'value': [{'key': 0, 'value': 'NULL'}, {'key': 0, 'value': 'null'}, {'key': 'NULL', 'value': 0}, {'key': 'null', 'value': 0}]}, {'key': 13, 'value': [{'key': True, 'value': 'true'}, {'key': False, 'value': 'false'}, {'key': 'false', 'value': False}, {'key': 'true', 'value': True}]}, {'key': 14, 'value': [{'key': '', 'value': 'emptyd'}, {'key': '', 'value': 'emptys'}, {'key': 'emptyd', 'value': ''}, {'key': 'emptys', 'value': ''}]}, {'key': 15, 'value': [{'key': 1, 'value': ''}, {'key': 2, 'value': ''}, {'key': 3, 'value': 0}, {'key': 4, 'value': 0}, {'key': 5, 'value': False}, {'key': 6, 'value': True}]}, {'key': 16, 'value': [{'key': '', 'value': 1}, {'key': '', 'value': 2}, {'key': 0, 'value': 3}, {'key': 0, 'value': 4}, {'key': False, 'value': 5}, {'key': True, 'value': 6}]}, {'key': 17, 'value': [{'key': 'One', 'value': 1}, {'key': 'two', 'value': 2}, {'key': 'One', 'value': 10}, {'key': 'two', 'value': 20}, {'key': 'three', 'value': 3}]}]

Stats

MD5 e5fba4e4494198bd761461b500940051
Eval Count 0
Decode Time 122 ms