I have a collection of possible sizes that I would like to trim, see as follows:
quantity_c_size_12_chain
quantity_c_size_12
quantity_size_12_chain
quantity_size_12
quantity_c_size_12_con_c
quantity_c_size_12_con_b
I would like to trim the string of all characters except the integer (in this example, 12)
At the moment I have this:
$size = preg_replace('#\d.*$#', '', $_GET['size']);
Unfortunately this does just the opposite of what I need, it strips the integer from the string and retains the alpha characters i.e. quantity_size_
Can anybody tell me what I need to do to remove everything except the integer?
Thanks,