3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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>"; ?>
based on pD0PI
Output for 7.2.0
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.10
<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 - 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>