3v4l.org

run code in 300+ PHP versions simultaneously
<?php function intvaljunk($string) { $boolSignedNegative = false; $intIntStart = null; $intIntEnd = null; foreach (str_split($string) as $index => $char) { if (is_numeric($char)) { $boolSignedNegative = ( $boolSignedNegative === false && $index > 0 && is_null($intIntStart) && $string[$index - 1] === '-' ? true : $boolSignedNegative ); $intIntStart = is_null($intIntStart) ? $index : $intIntStart; $intIntEnd = is_null($intIntStart) ? $intIntEnd : $index; } else if (!is_null($intIntStart) && !is_null($intIntStart)) { break; } } return ( !is_null($intIntStart) && !is_null($intIntStart) ? intval(($boolSignedNegative ? '-' : '') . substr($string, $intIntStart, ($intIntEnd - $intIntStart) + 1)) : null ); } $signed_number_strings = ["--1", "---33", "+-444"]; foreach ($signed_number_strings as $string) { var_dump(intvaljunk($string)); }
Output for rfc.property-hooks, git.master, git.master_jit
int(-1) int(-33) int(-444)

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.89 ms | 1627 KiB | 4 Q