summaryrefslogtreecommitdiff
path: root/ext/standard/tests/array/negative_index.phpt
blob: a9f442acbdbec78196817fa3b586c7bfff3391ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--TEST--
Test arrays starting with negative indices
--FILE--
<?php

$a = array_fill(-2, 3, true);
$b = [-2 => true, true, true];
$c = ["string" => true, -2 => true, true, true];
unset($c["string"]);
$d[-2] = true;
$d[] = true;
$d[] = true;
$e = [-2 => false];
array_pop($e);
$e[] = true;
$e[] = true;
$e[] = true;

var_dump($a === $b && $b === $c && $c === $d && $d == $e);
var_dump($a);
?>
--EXPECT--
bool(true)
array(3) {
  [-2]=>
  bool(true)
  [-1]=>
  bool(true)
  [0]=>
  bool(true)
}