<?php
$subjects = [
"りんご 150円 5個で 500円 (値引き 250円)",
"りんご 150円 3個で 450円 5個で 750円",
"りんご 150円 3個で 400円 (値引き 50円) 5個で 500円 (値引き 250円) (値引き 0円)(値引き 50円)(値引き 100円)(値引き 200円)"
];
foreach ($subjects as $s) {
preg_match("/^りんご (?<ringo_1>\d+)円(?: 3個で (?<ringo_3>\d+)円(?: \(値引き (?<nebiki_3>\d+)円\))?)?(?: 5個で (?<ringo_5>\d+)円(?: \(値引き (?<nebiki_5>\d+)円\))?)?.*$/", $s, $matches); unset($matches[0], $matches[1], $matches[2], $matches[3], $matches[4], $matches[5]); echo "{$ringo_1}, {$ringo_3}, {$nebiki_3}, {$ringo_5}, {$nebiki_5}\n";
}
PD9waHAKJHN1YmplY3RzID0gWwogICAgIuOCiuOCk+OBlCAxNTDlhoYgNeWAi+OBpyA1MDDlhoYgKOWApOW8leOBjSAyNTDlhoYpIiwKICAgICLjgorjgpPjgZQgMTUw5YaGIDPlgIvjgacgNDUw5YaGIDXlgIvjgacgNzUw5YaGIiwKICAgICLjgorjgpPjgZQgMTUw5YaGIDPlgIvjgacgNDAw5YaGICjlgKTlvJXjgY0gNTDlhoYpIDXlgIvjgacgNTAw5YaGICjlgKTlvJXjgY0gMjUw5YaGKSAo5YCk5byV44GNIDDlhoYpKOWApOW8leOBjSA1MOWGhiko5YCk5byV44GNIDEwMOWGhiko5YCk5byV44GNIDIwMOWGhikiCl07CiAKZm9yZWFjaCAoJHN1YmplY3RzIGFzICRzKSB7CiAgICBwcmVnX21hdGNoKCIvXuOCiuOCk+OBlCAoPzxyaW5nb18xPlxkKynlhoYoPzogM+WAi+OBpyAoPzxyaW5nb18zPlxkKynlhoYoPzogXCjlgKTlvJXjgY0gKD88bmViaWtpXzM+XGQrKeWGhlwpKT8pPyg/OiA15YCL44GnICg/PHJpbmdvXzU+XGQrKeWGhig/OiBcKOWApOW8leOBjSAoPzxuZWJpa2lfNT5cZCsp5YaGXCkpPyk/LiokLyIsICRzLCAkbWF0Y2hlcyk7CiAgICB1bnNldCgkbWF0Y2hlc1swXSwgJG1hdGNoZXNbMV0sICRtYXRjaGVzWzJdLCAkbWF0Y2hlc1szXSwgJG1hdGNoZXNbNF0sICRtYXRjaGVzWzVdKTsKICAgIGV4dHJhY3QoJG1hdGNoZXMpOwogICAgZWNobyAieyRyaW5nb18xfSwgeyRyaW5nb18zfSwgeyRuZWJpa2lfM30sIHskcmluZ29fNX0sIHskbmViaWtpXzV9XG4iOwp9Cgo=
150, , , 500, 250
150, 450, , 750, 250
150, 400, 50, 500, 250