3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_numerics ($str) { preg_match_all('/\d+/', $str, $matches); return $matches[0]; } $input = 'bubur 98k'; $inputNumbers = get_numerics($input); if (count($inputNumbers) !== 1) { // lebih dari 1 angka, atau angka null print_r("formatnya yang bener dong."); } else { $tempExpense = $inputNumbers[0]; // get index of first number occurence $pos = strpos($input, (string)$tempExpense); $k = ""; if (substr($input, $pos+1,1) === 'k') { // 3k $expense = $tempExpense * 1000; } elseif (substr($input, $pos+1,1) === '.') { // 100.300 } else { // 5000 $expense = $tempExpense; } print_r($tempExpense."k \n"); print_r($expense); }
Output for git.master, git.master_jit, rfc.property-hooks
98k 98

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:
50.81 ms | 401 KiB | 8 Q