I am little bit confused to get first and last value from array. And I tried to use explode()function but my logic is not working properly and very stupid logic.
My array
 Array
(
    [0] => 500 - 1112 
    [1] =>  1113 - 2224
    [2] => 2225 - 4446
    [3] => 4446 
)
I tried this way
$range = explode(',', $price_range);
        $count = count($range);
        if (1 == $count) {
            $price_1 = $range[0];
            $ranges['range1'] = explode(' - ', $price_1);
        } else if (2 == $count) {
            $price_1 = $range[0];
            $price_2 = $range[1];
            $ranges['range1'] = explode(' - ', $price_1);
            $ranges['range2'] = explode(' - ', $price_2);
        } else if (3 == $count) {
            $price_1 = $range[0];
            $price_2 = $range[1];
            $price_3 = $range[2];
            $ranges['range1'] = explode(' - ', $price_1);
            $ranges['range2'] = explode(' - ', $price_2);
            $ranges['range3'] = explode(' - ', $price_3);
        } else if (4 == $count) {
            $price_1 = $range[0];
            $price_2 = $range[1];
            $price_3 = $range[2];
            $price_4 = $range[3];
            $ranges['range1'] = explode(' - ', $price_1);
            $ranges['range2'] = explode(' - ', $price_2);
            $ranges['range3'] = explode(' - ', $price_3);
            $ranges['range4'] = explode(' - ', $price_4);
        }
     $array = call_user_func_array('array_merge', $ranges);
    sort($array);
    $min = reset($array);
    $max = end($array);
As per my array I want if in array getting single value in array for example
Array
(
    [0] => 500 - 1112 
    [1] =>  1113 - 2224
    [2] => 2225 - 4446
    [3] => 4446 
)
So I want to convert this array as shown below,
Array
(
    [0] => array(
        [0] => 500
        [1] => 1112 
        [2] => 1113 
        [3] => 2224
        [4] => 2225
        [5] => 4446
       )
    [1] => 4446 
)
And get min and max from Array ( [0] => array( from this array. Is their any simple way to do. 
Thanks in advance
                        
If I correctly understand your example, you provided it with the parameter
$countto2.So, this could be my version of your request:
The data
The function
The output
... and the result :)
If you need to repeat your code several times, it's because you can improve it. Here it's quick with a simple function.