Delete Magento Orders

by Doug Sparling

require 'app/Mage.php';
Mage::app('admin')->setUseSessionInUrl(false);                                   
$order_ids = array(
  'ordernumber1',
  'ordernumber2',
  'ordernumber3',
);

foreach ( $order_ids as $id ) {
    try {
        Mage::getModel('sales/order')->loadByIncrementId($id)->delete();
        echo "order #" . $id . " has been removed" . PHP_EOL;
    }catch(Exception $e){
        echo "order #" . $id . " could not be removed: " . $e->getMessage() . PHP_EOL;
    }
}
echo "Done..." . PHP_EOL;