I have a massive database storing customers' orders. I have to create a report (monthly and yearly) by total products sales and products brands sales.
The main trouble is that in every order entry, I got a column called items, which stores ordered products info like:
[32] (1 x 22 EUR) prod name wxy
Code:XY
Color:LRC Red Cherry [42] (1 x 33 EUR) prod name fgh
Code:XY
Color:pink [66] (1 x 44 EUR) prod name abc
Code:YU
Color:LPK Pink [60] (6 x 45 EUR) prd name xyz
Code:XY [1965] (1 x 32 EUR) prod name xyz
Code:XY
Color:Yellow [3413] (1 x 74 EUR) product name xyz
Code:XZ [22] (2 x 85 EUR) prod name zzz
Code:XY
Color: Black
The main advantage is that every line is separated by
and product ids are in square brackets.
Knowing that I've selected all MySQL entries in a while
loop, how could I get all product codes (in this example: 32, 42, 66, ... ) for each order entry (preferabble in an array)?
Rather, how to get only value 32 from this string:
[32] (1 x 22 EUR) prod name wxy
Code:XY
Color:LRC Red Cherry
Note: looking at first 2 lines, there is a <br/>
tag between
wxy
and
Code
, but there is always a "before" every [id].