Skip to content

Commit

Permalink
spread array test
Browse files Browse the repository at this point in the history
for #1102
  • Loading branch information
jakubmisek committed May 4, 2024
1 parent 28c530c commit 9b9f741
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions tests/arrays/spread_operator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
namespace arrays\spread_operator;

function test() {

$nums = [1,2,3];
$keyed = ['a' => 1, 'b' => 2, 'c' => 3];
$traversable = new \ArrayObject([1,2,3]);

print_r( [1, 2, 3, ...$nums] );
print_r( [1, 2, 3, ...$keyed] );
print_r( [1, 2, 3, ...$traversable] );
print_r( [...$nums, 0, 0, 0] );
}

test();
echo 'Done.';

0 comments on commit 9b9f741

Please sign in to comment.