<?php
$prices = array( "Red Pants" => 20, "Black Hats" => 15);
$items = "8 Red Pants, 2 Shirts, 6 Black Hats";
preg_match_all("/(?:(\d+) ([\w ])+,?)+/", $items, $matches);
print_r($matches);
- Output for 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
- Array
(
[0] => Array
(
[0] => 8 Red Pants,
[1] => 2 Shirts,
[2] => 6 Black Hats
)
[1] => Array
(
[0] => 8
[1] => 2
[2] => 6
)
[2] => Array
(
[0] => s
[1] => s
[2] => s
)
)
preferences:
172.5 ms | 405 KiB | 230 Q