Basically, I'm performing an if statement on an array based on the returned value<?phpif($array[1]>10000 AND $array[1]<50000){        $selling = $array[1] - 250;    }    elseif($array[1]>50000 AND $array[1]<100000){        $selling = $array[1] - 500;    }    else{        $selling = $array[1] - 100;    }    $buying = $array[1] - 1000;    if($array[1]>=10000){        $buying = $buying-1000;        if($array[1]>=20000){            $buying = $buying-1000;            if($array[1]>=30000){                $buying = $buying-1000;            }                if($array[1]>=40000){                    $buying = $buying-1000;                }                    if($array[1]>=50000){                        $buying = $buying-750;                    }                        if($array[1]>=60000){                            $buying = $buying-500;                        }                            if($array[1]>=70000){                                $buying = $buying-500;                            }        }       }?>As you can see it's VERY messy, would anyone be able to point me in the correct direction for cleaning this up please?
Cleaner method of doing IF
php
I seem to get the feeling you are either not comfortable using maps as others have suggested here...so why not throw in a switch instead?$volume = $array[1];if($volume > 10000 && $volume < 50000){    $selling = $volume - 250;} else if($volume > 50000 && $volume < 100000){    $selling = $volume - 500;} else {    $selling = $volume - 100;}$buying = $volume - 1000;switch($volume){    case 10000:    case 20000:    case 30000:    case 40000:        $buying = $buying - 1000; break;    case 50000:        $buying = $buying - 750; break;    case 60000:    case 70000:        $buying = $buying - 500; break;    default:        $buying = $buying;}REVISIT 01/26/2015: Revisiting this to say that I would now rewrite this code as follows:function bound_check($bounds, $bound_check, $default_value) {    $return_data = NULL;    foreach($bounds as $bound){        if($bound_check >= $bound[0] && $bound_check <= $bound[1]){            $return_data = $bound_check - $bound[2];        }    }    return $return_data ?: $default_value;}$selling_bounds = [    [10000, 50000, 250],    [50000, 100000, 500],];$buying_bounds = [    [10000, 40000, 1000],    [50000, 50000, 750],    [60000, 70000, 500]]$selling = bound_check($selling_bounds, $array[1], $volume - 100);$buying = bound_check($selling_bounds, $array[1], $volume - 1000);