summaryrefslogtreecommitdiff
path: root/tests/php/phpt/variables/008-value-arrays.phpt
blob: 69507800ec0098d1f2e4a93ccd10a9dcb243dd92 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
--TEST--
Test Php::Value arrays 
--DESCRIPTION--
--SKIPIF--
<?php if (!extension_loaded("extension_for_tests")) print "skip"; ?>
--FILEEOF--
<?php


$r = TestVariables\value_arrays();

    // To check:
/*
    $array;
    $array[0] = "apple";
    $array[1] = "banana";
    $array[2] = "tomato";

    // an initializer list can be used to create a filled array 
    $filled = ["a", "b", "c", "d"];

    // create an associative array
    $assoc["apple"] = "green";
    $assoc["banana"] = "yellow";
    $assoc["tomato"] = "green";

    // the variables in an array do not all have to be of the same type
    $assoc2["x"] = "info@example.com";
    $assoc2["y"] = NULL;
    $assoc2["z"] = 123;

    // nested arrays are possible too
    $assoc3["x"] = "info@example.com";
    $assoc3["y"] = NULL;
    $assoc3["z"][0] = "a";
    $assoc3["z"][1] = "b";
    $assoc3["z"][2] = "c";

    $r = [];
    $r["array"]  = $array;
    $r["filled"] = $filled;
    $r["assoc"]  = $assoc;
    $r["assoc2"] = $assoc2;
    $r["assoc3"] = $assoc3;
*/
    
var_export($r);



--EXPECT--
array (
  'array' => 
  array (
    0 => 'apple',
    1 => 'banana',
    2 => 'tomato',
  ),
  'filled' => 
  array (
    0 => 'a',
    1 => 'b',
    2 => 'c',
    3 => 'd',
  ),
  'assoc' => 
  array (
    'apple' => 'green',
    'banana' => 'yellow',
    'tomato' => 'green',
  ),
  'assoc2' => 
  array (
    'x' => 'info@example.com',
    'y' => NULL,
    'z' => 123,
  ),
  'assoc3' => 
  array (
    'x' => 'info@example.com',
    'y' => NULL,
    'z' => 
    array (
      0 => 'a',
      1 => 'b',
      2 => 'c',
    ),
  ),
)