summaryrefslogtreecommitdiffstats
path: root/system/libraries/Parser.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-01-20 14:03:43 +0100
committerAndrey Andreev <narf@devilix.net>2014-01-20 14:03:43 +0100
commitea801ab4ab80042638ffddc6056483a1ec43fa80 (patch)
treef75f30c0df6a8f861ca7df22af09fa3240b0bbd6 /system/libraries/Parser.php
parent1c08d557a21ecb0f79cd1a1de4e06817a26e0537 (diff)
parent4d0571666d03511ac5b4a1f2a6882ccb1509a209 (diff)
Merge branch 'develop' into feature/user-guide-cleanup
Diffstat (limited to 'system/libraries/Parser.php')
-rw-r--r--system/libraries/Parser.php30
1 files changed, 19 insertions, 11 deletions
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index c1f1ad73b..399131cdd 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -187,26 +187,34 @@ class CI_Parser {
*/
protected function _parse_pair($variable, $data, $string)
{
- if (FALSE === ($match = $this->_match_pair($string, $variable)))
+ if (FALSE === ($matches = $this->_match_pair($string, $variable)))
{
return $string;
}
$str = '';
- foreach ($data as $row)
+ $search = $replace = array();
+ foreach ($matches as $match)
{
- $temp = $match[1];
- foreach ($row as $key => $val)
+ $str = '';
+ foreach ($data as $row)
{
- $temp = is_array($val)
+ $temp = $match[1];
+ foreach ($row as $key => $val)
+ {
+ $temp = is_array($val)
? $this->_parse_pair($key, $val, $temp)
: $this->_parse_single($key, $val, $temp);
+ }
+
+ $str .= $temp;
}
- $str .= $temp;
+ $search[] = $match[0];
+ $replace[] = $str;
}
- return str_replace($match[0], $str, $string);
+ return str_replace($search, $replace, $string);
}
// --------------------------------------------------------------------
@@ -214,14 +222,14 @@ class CI_Parser {
/**
* Matches a variable pair
*
- * @param string
- * @param string
+ * @param string $string
+ * @param string $variable
* @return mixed
*/
protected function _match_pair($string, $variable)
{
- return preg_match('|'.preg_quote($this->l_delim).$variable.preg_quote($this->r_delim).'(.+?)'.preg_quote($this->l_delim).'/'.$variable.preg_quote($this->r_delim).'|s',
- $string, $match)
+ return preg_match_all('|'.preg_quote($this->l_delim).$variable.preg_quote($this->r_delim).'(.+?)'.preg_quote($this->l_delim).'/'.$variable.preg_quote($this->r_delim).'|s',
+ $string, $match, PREG_SET_ORDER)
? $match : FALSE;
}