Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Flattens and concatenates an array according to what QuickPay expects as parameters.
- *
- * @param array $parameters
- * The array to be flattened.
- * @param string $prefix
- * The prefix to add in front of every key.
- * @return array
- * Returns a flattened array with concatenated keys.
- */
- public function formatParameterArray(array $parameters, $prefix = '') {
- $result = [];
- foreach ($parameters as $key => $value) {
- if (empty($prefix)) {
- $new_key = $key;
- } else {
- $new_key = $prefix.'['.$key.']';
- }
- if (is_array($value)) {
- $result = array_merge($result, $this->formatParameterArray($value, $new_key));
- } else {
- $result[$new_key] = $value;
- }
- }
- return $result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement