|
127 | 127 | <programlisting role="php">
|
128 | 128 | <![CDATA[
|
129 | 129 | <?php
|
130 |
| -echo min(2, 3, 1, 6, 7); // 1 |
131 |
| -echo min(array(2, 4, 5)); // 2 |
| 130 | +echo min(2, 3, 1, 6, 7), PHP_EOL; // 1 |
| 131 | +echo min(array(2, 4, 5)), PHP_EOL; // 2 |
132 | 132 |
|
133 | 133 | // Here we are comparing -1 < 0, so -1 is the lowest value
|
134 |
| -echo min('hello', -1); // -1 |
| 134 | +echo min('hello', -1), PHP_EOL; // -1 |
135 | 135 |
|
136 | 136 | // With multiple arrays of different lengths, min returns the shortest
|
137 | 137 | $val = min(array(2, 2, 2), array(1, 1, 1, 1)); // array(2, 2, 2)
|
| 138 | +var_dump($val); |
138 | 139 |
|
139 | 140 | // Multiple arrays of the same length are compared from left to right
|
140 | 141 | // so in our example: 2 == 2, but 4 < 5
|
141 | 142 | $val = min(array(2, 4, 8), array(2, 5, 1)); // array(2, 4, 8)
|
| 143 | +var_dump($val); |
142 | 144 |
|
143 | 145 | // If both an array and non-array are given, the array is never returned
|
144 | 146 | // as comparisons treat arrays as greater than any other value
|
145 | 147 | $val = min('string', array(2, 5, 7), 42); // string
|
| 148 | +var_dump($val); |
146 | 149 |
|
147 | 150 | // If one argument is NULL or a boolean, it will be compared against
|
148 | 151 | // other values using the rules FALSE < TRUE and NULL == FALSE regardless of the
|
149 | 152 | // other types involved
|
150 | 153 | // In the below examples, both -10 and 10 are treated as TRUE in the comparison
|
151 | 154 | $val = min(-10, FALSE, 10); // FALSE
|
| 155 | +var_dump($val); |
| 156 | +
|
152 | 157 | $val = min(-10, NULL, 10); // NULL
|
| 158 | +var_dump($val); |
153 | 159 |
|
154 | 160 | // 0, on the other hand, is treated as FALSE, so is "lower than" TRUE
|
155 | 161 | $val = min(0, TRUE); // 0
|
| 162 | +var_dump($val); |
156 | 163 | ?>
|
157 | 164 | ]]>
|
158 | 165 | </programlisting>
|
|
0 commit comments