From 7e38669f2aa8f10819551ea90e0c9a7ac4970072 Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 14 Sep 2011 15:45:39 +0000 Subject: ITools-stylify transmogrify code --- it_text.class | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/it_text.class b/it_text.class index 3264169..edfdd43 100644 --- a/it_text.class +++ b/it_text.class @@ -218,11 +218,9 @@ function set($label, $text = null, $language = null) */ function transmogrify($text, $values = null) { - foreach (preg_split('/{([\w.]+)}/', $text, -1, PREG_SPLIT_DELIM_CAPTURE) as $idx => $part) + foreach (preg_split('/{([\w.]+)}/', $text, -1, PREG_SPLIT_DELIM_CAPTURE) as $i => $part) { - if ($idx % 2 == 0) # even offsets are between delimiters - $result .= $part; - else + if ($i % 2) # odd offsets are delimiters, i.e. braces to be replaced { $value = $values ? $values : $GLOBALS; foreach (explode(".", $part) as $key) @@ -235,6 +233,8 @@ function transmogrify($text, $values = null) $result .= $value; } + else + $result .= $part; } return $result; -- cgit v1.2.3