From fefb118c589af3028518c63af0130963d4e0a9e9 Mon Sep 17 00:00:00 2001 From: Silvio Date: Mon, 28 Jun 2010 11:36:29 -0300 Subject: Adding useful methods for bracket handling at IsisConnector --- classes/IsisConnector.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'classes/IsisConnector.php') diff --git a/classes/IsisConnector.php b/classes/IsisConnector.php index 6467959..4e53535 100644 --- a/classes/IsisConnector.php +++ b/classes/IsisConnector.php @@ -243,4 +243,43 @@ class IsisConnector { return $keys[$subfield]; } } + + /** + * Remove brackets from strings whithin an array. + * + * @param &$values + * Array with bracketed strings. + */ + public function removeBrackets($value) { + $value = str_replace('<', '', $value); + $value = str_replace('>', '', $value); + return $value; + } + + /** + * Remove brackets from strings whithin an array. + * + * @param &$values + * Array with bracketed strings. + */ + public function removeBracketsFromArray(&$values) { + foreach ($values as $key => $value) { + $values[$key] = $this->removeBrackets($value); + } + } + + /** + * Explode a bracketed string into values. Just strings + * inside brackets are returned. + * + * @param $subject + * Strings containing brackets. + * + * @return + * Array of matched strings. + */ + public function explodeBrackets($subject) { + $values = preg_split('/[<\s>]+/', $subject, -1, PREG_SPLIT_NO_EMPTY); + return $values; + } } -- cgit v1.2.3