I'm having a long text in a string:

```
$data = "899.3MB 976.4MB 874.7MB 985.6MB 1.2GB 691.3MB 1.4GB 975.4MB 1.0GB 712.8MB 879.8MB 908.6MB 912.1MB 887.5MB 950.4MB 1.4GB 749.9MB 851.2MB 750.8MB 813.7MB 1.2GB 700MB 998.5MB 1010.8MB 989.7MB 1.1GB 797.5MB 699.5MB 683.7MB 1.0GB 958.2MB 1.1GB 1.0GB 1.0GB 1.0GB 1.1GB 1.0GB 1.0GB 846MB 873MB 753MB 1.1GB 970MB 749.9MB 750MB 650MB 845MB 1.1GB 1.3GB 1.2GB 1.1GB 867MB 940MB 946MB 909MB 909MB 913MB 893MB 892MB 889MB 730MB 848MB 855MB 1.15GB 853MB 765MB 1.2GB 863MB 838MB 753MB 960MB 868MB 967MB 1.06GB 751MB 1GB 1.2GB 920MB 1.2GB 897MB 1009.15MB 764MB 694MB 967MB 989.9MB 898MB 938MB 879.76MB 879.76MB 999.78MB 1.3GB 1.1GB 1.09GB"

```

How can I arrange them in different variables after sorting them. Like `$mb` will contain only those values which ends with MB and `$gb` will contain only those values which ends with GB. And also I don't want MB and GB in output I just want the `float` or `int` values so that I can Add them.

I'm importing this data from MySql database in which there is a column named `file_size`

```
while ($data = mysqli_fetch_array($records))
{
$file_size_ext = str_replace(' ', '',$data['file_size'])." "; 

}
mysqli_close($db);
?>

```

I tried to arrange them separately by `echo substr("$file_size_ext",-2) =='GB'` but there's nothing like this in PHP .

I just want to separate them into `MB` and `GB` so that I can add or get sum of the array "separately".

I should probably modify my database and write all the file sizes in same unit, then it will be much more easier..