*/ /** * patTemplate modifier Reverse * * Reverse words using custom separator * * @package patTemplate * @package Modifiers * @author gERD Schaufelberger */ class patTemplate_Modifier_Reverse extends patTemplate_Modifier { /** * modify the value * * @param string value * @param array $params * @return string modified value */ public function modify( $value, $params = array() ) { if (!is_array($params)) { $params = array(); } $default = array( 'separator' => '.', 'fill' => '.' ); $params = array_merge($default, $params); // nothing to do if (empty($params['separator'])) { return $value; } $value = explode($params['separator'], $value); $value = array_reverse($value); $value = implode($params['fill'], $value); return $value; } }