handles newlines in REGEXPS matches. Set the _hmr_* vars before calling this

@note this is a callback, don't use it directly

@param array the matches array
@return string
@since 1.0.8
@access private
421518
function handle_multiline_regexps($matches) {
        $before = $this->_hmr_before;
        $after = $this->_hmr_after;
        if ($this->_hmr_replace) {
            $replace = $this->_hmr_replace;
            $search = array();

            foreach (array_keys($matches) as $k) {
                $search[] = '\\' . $k;
            }

            $before = str_replace($search, $matches, $before);
            $after = str_replace($search, $matches, $after);
            $replace = str_replace($search, $matches, $replace);
        } else {
            $replace = $matches[0];
        }
        return $before
                    . '<|!REG3XP' . $this->_hmr_key .'!>'
                        . str_replace("\n", "|>\n<|!REG3XP" . $this->_hmr_key . '!>', $replace)
                    . '|>'
              . $after;
    }
470303
protected function implodeArray(array $array)
    {
        $results = [];

        foreach ($array as $key => $value) {
            if (is_string($key)) {
                $results[] = "'".$key."' => '".$value."'";
            } else {
                $results[] = "'".$value."'";
            }
        }

        return count($results) > 0 ? implode(', ', $results) : '';
    }
990891
private function arrayToPlainText(array $array, $title = null): string
    {
        $root = 'error';
        $text = '';

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                if ($title !== null) {
                    $key = $title . '.' . $key;
                }
                $text .= $this->arrayToPlainText($value, $key);
            } else {
                if (is_null($value) || is_object($value)) {
                    $value = json_encode($value);
                }
                if (is_bool($value)) {
                    $value = ($value) ? 'true' : 'false';
                }
                if ($title != '') {
                    $text .= $root . '.' . $title . '.' . $key . ': ' . $value . PHP_EOL;
                } else {
                    $text .= $root . '.' . $key . ': ' . $value . PHP_EOL;
                }
            }
        }

        return $text;
    }
1054525
public static String[] trim(String[] array) {
	int from = 0;
	int to = 0;

	// test start
	for (int i = 0; i < array.length; i++) {
	    from = i;
	    if (array[i].length() != 0) break;
	}

	// test end
	for (int i = array.length - 1; i >= 0; i--) {
	    to = i;
	    if (array[i].length() != 0) break;
	}

	int newLen = to - from + 1;

	if (newLen < array.length) {
	    String[] rtn = new String[newLen];
	    System.arraycopy(array, from, rtn, 0, newLen);
	    return rtn;
	}
	return array;
    }
1044859
private function func_arr_params_callback($matches) {
    	$func = $matches[1];
    	$params_str = $matches[2];
        $in_matches = [];
    	preg_match_all("/([a-z_]+)\=[\"\']?([^\"\']+)[\"\']?/i", stripslashes($params_str), $in_matches, PREG_SET_ORDER);
    	$params = null;
    	foreach($in_matches as $v) {
    		$params[$v[1]] = $v[2];
    	}
    	return "<?php print_r( " . $func . "(" . ArrayHelper::toRaw($params) . ') ); ?>';
    }
1055172
public function merge_4value_radius_shorthands($array) {
		$return = $array;
		$shorthands = & $this->parser->data['csstidy']['radius_shorthands'];

		foreach ($shorthands as $key => $value) {
			if (isset($array[$value[0]]) && isset($array[$value[1]])
							&& isset($array[$value[2]]) && isset($array[$value[3]]) && $value !== 0) {
				$return[$key] = '';
				$a = array();
				for ($i = 0; $i < 4; $i++) {
					$v = $this->explode_ws(' ', trim($array[$value[$i]]));
					$a[0][$value[$i]] = reset($v);
					$a[1][$value[$i]] = end($v);
				}
				$r = array();
				$r[0] = $this->merge_4value_shorthands($a[0], $shorthands);
				$r[1] = $this->merge_4value_shorthands($a[1], $shorthands);

				if (isset($r[0][$key]) and isset($r[1][$key])) {
					$return[$key] = $r[0][$key];
					if ($r[1][$key] !== $r[0][$key]) {
						$return[$key] .= ' / ' . $r[1][$key];
					}
					for ($i = 0; $i < 4; $i++) {
						unset($return[$value[$i]]);
					}
				}
			}
		}
		return $return;
	}
1097524
public String format(Object... array) {
    if (array == null) {
      return StringUtils.EMPTY;
    }
    if (array.length == 1 && array[0].getClass().isArray()) {
      return format(Convert.convert(array[0], Iterable.class));
    }
    return format(Arrays.asList(array).iterator());
  }
1179318
public function regex($array = [])
    {
        $filtered = [];
        foreach ($array as $key => $value) {
            if ($this->isRegex($key)) {
                $filtered[$key] = $value;
            }
        }

        return $filtered;
    }
1211982
protected static function p(array $matches)
    {
        $line = $matches[1];
        $trimmed = trim($line);

        if (preg_match('/^<\/?(ul|ol|li|h|p|bl)/', $trimmed)) {
            return "\n$line\n";
        }

        return sprintf("\n<p>%s</p>\n", $trimmed);
    }
229266
public static function array_strip_tags($array) {
    $result = array();

    foreach ( $array as $key => $value ) {
      $key = strip_tags($key);

      if (is_array($value)) {
        $result[$key] = self::array_strip_tags($value);
      } else if (is_numeric($value) && !preg_match('/^0\d+$/', $value)) {
        $result[$key] = $value + 0;
      } else {
        $result[$key] = htmlspecialchars(trim(strip_tags($value)), ENT_QUOTES | ENT_HTML5);
      }
    }

    return $result;
  }
752263
public function newLine($count = 1) {

        // send out any escaping to implement anything sitting in the desired state
        $this->outputEscapeSequence();

        // if the $count is greater than one
        if (is_int($count) && $count > 1) {

            // send out the \n $count times
            for ($i=0; $i<$count; ++$i) {

                // echo the newline character
                $this->output("\n");
            }

        } else {
            // the parameter might be one or something crazy, just output one
            // echo the new line character
            $this->output("\n");
        }

        // fire the handler that indicates the cursor is sent to the left margin
        $this->carriageReturn();

        // chaining
        return $this;
    }
779148
protected function implode( $array )
    {
        $retString = '';
        if ( empty( $array ) )
        {
            return '';
        }
        foreach ( $array as $key => $value )
        {
            if ( is_array( $value ) )
            {
                $value = $this->implode( $value );
            }
            $retString .= $key . ' ' . $value . ' ';
        }

        return $retString;
    }
666708
public static String[] toStringArrayTrim(Array array) throws PageException {
	String[] arr = new String[array.size()];
	for (int i = 0; i < arr.length; i++) {
	    arr[i] = Caster.toString(array.get(i + 1, "")).trim();
	}

	return arr;
    }
942443
private function NormalizeArray($Array) {
      $Return = array();
      foreach ($Array as $Key => $Value) {
         if (is_array($Value) === TRUE && array_key_exists(0, $Value) === FALSE) {
            foreach($Value as $k => $v) {
               $Return[$Key.'.'.$k] = $v;
            }
         } else {
            $Return[$Key] = $Value;
         }
      }
      return $Return;
   }
1290
function trimEndBlankLines(array) {

    if (!array || array.length < 1) {
        return array;
    }

    let temp;
    while (array.length > 0) {
        temp = array[array.length - 1];
        if (temp === '' || Str.trim(temp, ' \t') === '') {
            array.pop();
        } else {
            break;
        }
    }

    return array;

}
849464
function (array, maxLength)
        {
            var result =
            this.replaceStringArray(array, [FALSE_FREE_DELIMITER], null, false, maxLength);
            return result;
        }
1061609
protected function getWordsRegexp(array $words)
	{
		$expr  = RegexpBuilder::fromList($words, $this->regexpOptions);
		$regexp = new Regexp('/(?<![\\pL\\pN])' . $expr . '(?![\\pL\\pN])/Siu');

		// JavaScript regexps don't support Unicode properties, so instead of Unicode letters
		// we'll accept any non-whitespace, non-common punctuation
		$expr = str_replace('[\\pL\\pN]', '[^\\s!-\\/:-?]', $expr);
		$expr = str_replace('(?>',        '(?:',            $expr);
		$regexp->setJS('/(?:^|\\W)' . $expr . '(?!\\w)/gi');

		return $regexp;
	}