I'm parsing some data and standardizing it for my website. The data I get from parsing:
[sizes] => Array
(
[0] => 5
[1] => 6
[2] => 10
[3] => 6+
[4] => 7
[5] => 7+
[6] => 8
[7] => 8+
[8] => 9
)
I need to get:
[0] => US - 5
[1] => US - 6
[2] => US - 10
[3] => US - 6.5
[4] => US - 7.5
[5] => US - 8.5
I tried both preg_replace (all kind of different variations) and str_replace, but nothing seem to work. It seems like it overwrites values:
$sizes[$i]= str_replace("7", "US - 7", $sizes[$i]);
$sizes[$i] = preg_replace('/\b6\b/', "US - 6", $sizes[$i]);
$sizes[$i] = preg_replace('~6\+$~m', "US - 6.5", $sizes[$i]);
$sizes[$i] = preg_replace('~5+$~m', "US - 5.5", $sizes[$i]);
I get back something like that:
[0] => US - 10
[1] => US - 5.US - 5
[2] => US - 6
[3] => US - 6.US - 5.US - 5
[4] => US - 7
[5] => US - 8
[6] => US - 9
[7] => US - US - 7.5
[8] => US - US - 8.5
If anyone could help, I'd appreciate it. Thank you