3v4l.org

run code in 300+ PHP versions simultaneously
<?php $records = [ ['1', '2'], ['3', '9'], ['12', '8' ], ['20', '2' ], ['22', '15' ], ['37', '16' ], ['53', '16' ], ['69', '16' ], ['85', '1' ], ['86', '4' ], ['90', '4' ], ['94', '4' ], ['98', '4' ], ['102', '4', '5' ], ['106+X', 'X'], ['106+X', '5', '10'], ['111+X', 'Y'], ['111+X+Y', '7', '20'], ['118+X+Y', 'Z'], ]; $X = 10; $Y = 15; $Z = 5; foreach ($records as $posLen) { $pos = $posLen[0]; $len = $posLen[1]; // $val = $posLen[2]; // if $len is a character, then it represents a variable. if (!is_numeric($len)) { $len = $$len; } $finalPos = 0; $posArray = explode('+', $pos); foreach($posArray as $posItem) { if (is_numeric($posItem)) { $finalPos += $posItem; } else { $finalPos += $$posItem; } } echo "$finalPos, $len" . PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
1, 2 3, 9 12, 8 20, 2 22, 15 37, 16 53, 16 69, 16 85, 1 86, 4 90, 4 94, 4 98, 4 102, 4 116, 10 116, 5 121, 15 136, 7 143, 5

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
45.66 ms | 401 KiB | 8 Q