<?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('Нет в наличии');
You have javascript disabled. You will not be able to edit any code.