*/ /** * patTemplate modifier Substr * * Parameter: * * @package patTemplate * @package Modifiers * @author gERD Schaufelberger */ class patTemplate_Modifier_Substr extends patTemplate_Modifier { /** * Modify the value * * * @see substr() * @param string value * @param array list of parameter * @return string modified value */ public function modify($value, $params = array()) { $params = array_merge(array( 'start' => 0, 'length' => '__NULL', ), $params); $value = strval($value); if (empty($value)) { return ''; } $params['start'] = intval($params['start']); if ('__NULL' == $params['length']) { return substr($value, $params['start']); } $params['length'] = intval($params['length']); return substr($value, $params['start'], $params['length']); } }