Flattens input data

@param string  $str   Input string
@param array   $args  Variables to be replaced

@return array
186730
public static function flatten($data, $flat = array(), $prefix = '')
    {
        foreach ($data as $key => $value) {

            // is array -> flatten deeped
            if (is_array($value)) {
                $flat = self::flatten($value, $flat, $prefix. $key. self::$FLATTEN_SEPARATOR);
            }
            // scalar -> use
            else {
                $flat[$prefix. $key] = $value;
            }
        }
        return $flat;
    }
1033903
public static String format(String str, Object... args) {
        str = str.replaceAll("\\{}", "%s");

        return String.format(str, args);
    }
368477
public static function stringToArray($str)
    {
        $arr = [];

        for ($i = 0; $i < self::stringLength($str); $i++) {
            $arr[] = function_exists('mb_substr') ? mb_substr($str, $i, 1) : $str[$i];
        }

        return $arr;
    }
1052147
public function interpolate($msg, array $args = array())
    {
        preg_match_all('/(?<!%)(?:%%)*%\\(([^\\)]*)\\)/', $msg, $matches);
        // Only define the variables if there are any.
        if (isset($matches[1][0])) {
            $args += array_combine(
                $matches[1],
                array_fill(0, count($matches[1]), null)
            );
        }

        if (!count($args)) {
            return $msg;
        }

        // Mapping = array(name => index)
        $keys       = array_keys($args);
        $mapping    = array_flip($keys);
        $keys       = array_map(
            function ($key) {
                return "%($key)";
            },
            $keys
        );
        $values     = array_map(
            function ($val) {
                return '%'.($val + 1).'$';
            },
            $mapping
        );
        $mapping    = array_combine($keys, $values);
        $msg        = strtr($msg, $mapping);
        return vsprintf($msg, array_values($args));
    }
130586
public static function strSplit($str, $length = 1) {
		if ($length < 1) {
			return [];
		}
		$result = [];
		$c = mb_strlen($str);
		for ($i = 0; $i < $c; $i += $length) {
			$result[] = mb_substr($str, $i, $length);
		}
		return $result;
	}
746069
function flatten (arr) {
  return arr.reduce(function (acc, curr) {
    return acc.concat(Array.isArray(curr) ? flatten(curr) : curr)
  }, [])
}
1243722
protected function _flattern_objects($arg, $return_comma_list = false)
    {
        /*
         * This function is very similar to json_encode, however it will traverse array
         * before encoding in search of objects based on AbstractObject. Those would
         * be replaced with their json representation if function exists, otherwise
         * with string representation
         */
        if (is_object($arg)) {
            if ($arg instanceof self) {
                $r = $arg->_render();
                if (substr($r, -1) == ';') {
                    $r = substr($r, 0, -1);
                }

                return $r;
            } elseif ($arg instanceof AbstractView) {
                return "'#".$arg->getJSID()."'";
            } else {
                return "'".$this->_safe_js_string((string) $arg)."'";    // indirectly call toString();
            }
        } elseif (is_array($arg)) {
            $a2 = array();
            // is array associative? (hash)
            $assoc = $arg != array_values($arg);

            foreach ($arg as $key => $value) {
                $value = $this->_flattern_objects($value);
                $key = $this->_flattern_objects($key);
                if (!$assoc || $return_comma_list) {
                    $a2[] = $value;
                } else {
                    $a2[] = $key.':'.$value;
                }
            }
            if ($return_comma_list) {
                $s = implode(',', $a2);
            } elseif ($assoc) {
                $s = '{'.implode(',', $a2).'}';
            } else {
                $s = '['.implode(',', $a2).']';
            }
        } elseif (is_string($arg)) {
            $s = "'".$this->_safe_js_string($arg)."'";
        } elseif (is_bool($arg)) {
            $s = json_encode($arg);
        } elseif (is_numeric($arg)) {
            $s = json_encode($arg);
        } elseif (is_null($arg)) {
            $s = json_encode($arg);
        } else {
            throw $this->exception('Unable to encode value for jQuery Chain - unknown type')
                ->addMoreInfo('arg', var_export($arg, true));
        }

        return $s;
    }
690745
public function prepend($str)
    {
        $value = $this->val();
        $this->val($str . $value);

        return $this;
    }
219264
protected function translate($str, $params = array())
    {
        if (isset($this->translator)) {
            return $this->translator->trans($str, $params);
        }
        else {
            $finalParams = array();
            foreach ($params as $placeholder => $value) {
                $finalParams['{'.$placeholder.'}'] = $value;
            }
            return strtr($str, $finalParams);
        }
    }
1337647
public static function str2array($str, $sep = ',')
    {
        $str = trim($str, "$sep ");

        if (!$str) {
            return [];
        }

        return preg_split("/\s*$sep\s*/", $str, -1, PREG_SPLIT_NO_EMPTY);
    }
1360541
private function _toupper($str)
    {
        // string can containing HTML tags
        $chunks = preg_split('/(<[^>]*>)/', $str, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);

        // convert toupper only the text between HTML tags
        foreach ($chunks as $idx => $chunk) {
            if ($chunk[0] != '<') {
                $chunks[$idx] = $this->_strtoupper($chunk);
            }
        }

        return implode($chunks);
    }
1093590
protected static function prepareValueS($str, array $params = [])
    {
        $result = $str;
        foreach ($params as $key => $value) {
            $result = str_replace('{'.$key.'}', $value, $result);
        }
        return $result;
    }
1310058
protected function flattenArguments()
	{
		$args = func_get_args();
		$flat = [];

		foreach ($args as $arg) {
			if (is_array($arg)) {
				$flat = call_user_func_array(array($this, 'flattenArguments'), array_merge($flat, $arg));
				continue;
			}
			array_push($flat, $arg);
		}

		return $flat;
	}
481757
public static function replaceRomanArray(array $str) : array
    {
        foreach ($str as $key => $value) {
            $code = Mbstring::mb_ord($value);
            if ($code >= 8544 && $code <= 8555) {
                $str[$key] = self::toRoman($code - 8543);
            } elseif ($code >= 8560 && $code <= 8571) {
                $str[$key] = self::toSmallRoman($code - 8559);
            } else {
                switch ($code) {
                    case 8556:
                        $str[$key] = self::toRoman(50);
                        break;
                    case 8557:
                        $str[$key] = self::toRoman(100);
                        break;
                    case 8558:
                        $str[$key] = self::toRoman(500);
                        break;
                    case 8559:
                        $str[$key] = self::toRoman(1000);
                        break;
                    case 8572:
                        $str[$key] = self::toSmallRoman(50);
                        break;
                    case 8573:
                        $str[$key] = self::toSmallRoman(100);
                        break;
                    case 8574:
                        $str[$key] = self::toSmallRoman(500);
                        break;
                    case 8575:
                        $str[$key] = self::toSmallRoman(1000);
                        break;
                    default:
                        break;
                }
            }
        }
        return $str;
    }
130806
private function cleanInputData($str) {
        if (is_array($str)) {
            $new_array = [];
            foreach ($str as $key => $val) {
                $new_array [ $this->cleanInputKeys($key) ] = $this->cleanInputData($val);
            }

            return $new_array;
        }
        $str = self::$xss_cleaner->xss_clean($str);
        // Standardize newlines
        if (strpos($str, "\r") !== false) {
            $str = str_replace(["\r\n", "\r"], "\n", $str);
        }

        return $str;
    }
149570
static function strReplace($str,$params)
    {
        foreach ($params as $k=>$v) {
            $str = str_replace($k, $v, $str);
        }
        return $str;
    }
1236845
public function input($arg,...$args){
        /** $args != null */
        if($args) {
            if(is_array($args[0])) {
                //$this->input('get',['name','pass']);
                $args = [$arg,$args[0]];
            }
            else {
                //$this->input('name','pass');
                array_unshift($args,$arg);
                $args = [$this->method,$args];
            }
        }
        else {
            /** $args == null */
            //$this->input('name');
            //$this->input(['name','pass']);
            $args = [$this->method,$arg];
        }

        $input = call_user_func_array([$this,'form'],$args);

        if(is_array($input) === false) {
            return null;
        }

        if(count($input) == 1) {
            return current($input);
        }

        return array_values($input);
    }