Search code examples
phppreg-match

preg_match length width height


I open a csv-file in php and I do have columns with multiple rows that looks like this:

1 | Some word 18x140x2000mm another word
2 | 20x150x300cm couple other words
3 | new words 30x140x2100mm

How do I get with preg_match the length, height, width in the string and even the unit cm, mm.

1 | $attributes = array(18, 140, 2000, mm);
2 | ...

Thanks for help!


Solution

  • Have You Try This?

    (\d+)x(\d+)x(\d+)(\w+)
    

    please let me know if it doesn't work..