I’m looking for a way to separate number from its unit – like 400px (400 + px), 30em (30 + em), 5% (5 + %) etc.
It’s perhaps something simple but I couldn’t find any pre-made functions in PHP manual to do that.
Let’s say that I have this:
$variable = "50px";
// and this is what I need:
$result = array(50, 'px');
try This
than you will get array like
and now you can get
Codepad