3v4l.org

run code in 300+ PHP versions simultaneously
<?php $in = "0 0 0 0 0.5230792 0 0 0 0.4769208 0 0 0 "; $data = preg_split("/[\s\n]/",$in); $count = count($in); $length = 1000; $size = $length/$count; $height = 100; print "<svg width='$length' height='$height'>"; $x = 0; foreach ($data as $line) { $inte = floor($line*255); print "<rect x='$x' y='0' width='$size' height='$height' style='fill:rgb($inte,$inte,$inte);stroke-width:1;stroke:white' />"; $x = $x+$size; } print "</svg>"; ?>
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /in/uXJX4:6 Stack trace: #0 {main} thrown in /in/uXJX4 on line 6
Process exited with code 255.
Output for 8.0.0 - 8.0.9
Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, string given in /in/uXJX4:6 Stack trace: #0 {main} thrown in /in/uXJX4 on line 6
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: count(): Parameter must be an array or an object that implements Countable in /in/uXJX4 on line 6 <svg width='1000' height='100'><rect x='0' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='1000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='2000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='3000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='4000' y='0' width='1000' height='100' style='fill:rgb(133,133,133);stroke-width:1;stroke:white' /><rect x='5000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='6000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='7000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='8000' y='0' width='1000' height='100' style='fill:rgb(121,121,121);stroke-width:1;stroke:white' /><rect x='9000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='10000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='11000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /> Warning: A non-numeric value encountered in /in/uXJX4 on line 13 <rect x='12000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /></svg>
Output for 7.1.0 - 7.1.20
<svg width='1000' height='100'><rect x='0' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='1000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='2000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='3000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='4000' y='0' width='1000' height='100' style='fill:rgb(133,133,133);stroke-width:1;stroke:white' /><rect x='5000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='6000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='7000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='8000' y='0' width='1000' height='100' style='fill:rgb(121,121,121);stroke-width:1;stroke:white' /><rect x='9000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='10000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='11000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /> Warning: A non-numeric value encountered in /in/uXJX4 on line 13 <rect x='12000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /></svg>
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20
<svg width='1000' height='100'><rect x='0' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='1000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='2000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='3000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='4000' y='0' width='1000' height='100' style='fill:rgb(133,133,133);stroke-width:1;stroke:white' /><rect x='5000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='6000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='7000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='8000' y='0' width='1000' height='100' style='fill:rgb(121,121,121);stroke-width:1;stroke:white' /><rect x='9000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='10000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='11000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /><rect x='12000' y='0' width='1000' height='100' style='fill:rgb(0,0,0);stroke-width:1;stroke:white' /></svg>

preferences:
253.69 ms | 406 KiB | 312 Q