3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parsePrice(string $price): int { // 0 - рубли, 1 - копейки $price = trim(str_replace(['руб.', ' ',], ['', ''], $price)); $price = str_replace(',', '.', $price); $priceExp = []; $amount = 0; if (str_contains($price, '.')) { $priceExp = explode('.', $price); $amount = (int) str_pad(substr($priceExp[1], 0, 2), 2, '0'); } return (int) ($priceExp[0] ?? $price) * 100 + $amount; } print parsePrice('Нет в наличии');
Output for git.master_jit, git.master
0

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:
42.45 ms | 405 KiB | 5 Q