From: Iain Patterson Date: Mon, 13 May 2013 08:49:20 +0000 (-0400) Subject: Formatting in get_order_parcel_string(). X-Git-Tag: 2013-05-13~13 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=cc703b79a6e9d646b44bdf63df58b48162b80856;p=readifood.git Formatting in get_order_parcel_string(). Make sure the output of get_order_parcel_string() doesn't include any leading or trailing colons. --- diff --git a/lib/functions.php b/lib/functions.php index fe442f8..ecaf2ad 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -219,7 +219,7 @@ function get_order_parcel_string($order) { global $parcel_sizes, $parcel_contents; - $parcel_size = ""; + $parcel_size = null; for ($i = 0 ; $i < count($parcel_sizes); $i++) { if ($order->getParcel() & (1 << $i)) { $parcel_size = $parcel_sizes[$i]; @@ -232,7 +232,11 @@ if ($order->getParcel() & (1 << $i)) $selected[] = $parcel_contents[$i]; } - return implode(": ", array($parcel_size, implode(", ", $selected))); + $ret = implode(": ", array($parcel_size, implode(", ", $selected))); + $ret = preg_replace('/^: /', '', $ret); + $ret = preg_replace('/: $/', '', $ret); + + return $ret; } function get_order_displayname($order) {