3v4l.org

run code in 300+ PHP versions simultaneously
<?php function roundToValues( $tax, array $possibleTaxes ) { $differences = array(); foreach( $possibleTaxes as $possibleTax) { $differences[ $possibleTax ] = abs($possibleTax - $tax); } return array_search(floor($differences), $differences); } $possibleTaxes = array( '0' => '0', '20' => '0-20', '50' => '20-50', '100' => '50-100', '200' => '100-200', '500' => '200-500', ); var_dump( roundToValues('199.99',$possibleTaxes) ); ?>
Output for git.master, git.master_jit, rfc.property-hooks
Warning: A non-numeric value encountered in /in/iIviZ on line 5 Warning: A non-numeric value encountered in /in/iIviZ on line 5 Warning: A non-numeric value encountered in /in/iIviZ on line 5 Warning: A non-numeric value encountered in /in/iIviZ on line 5 Warning: A non-numeric value encountered in /in/iIviZ on line 5 Fatal error: Uncaught TypeError: floor(): Argument #1 ($num) must be of type int|float, array given in /in/iIviZ:7 Stack trace: #0 /in/iIviZ(7): floor(Array) #1 /in/iIviZ(18): roundToValues('199.99', Array) #2 {main} thrown in /in/iIviZ on line 7
Process exited with code 255.

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:
46.59 ms | 402 KiB | 8 Q