Skip to content
Snippets Groups Projects
Commit b795dd8b authored by Carsten  Rose's avatar Carsten Rose
Browse files

onArray: enhanced phpdoc. Extended toString() with 'encloseValue'

parent a4cddb3e
No related branches found
No related tags found
No related merge requests found
...@@ -18,16 +18,22 @@ require_once(__DIR__ . '/../../qfq/Constants.php'); ...@@ -18,16 +18,22 @@ require_once(__DIR__ . '/../../qfq/Constants.php');
class OnArray { class OnArray {
/** /**
* Builds a string from an assoc array.
*
* key/value are combined with $keyValueGlue.
* values are enclosed by $encloseValue.
* rows combined with $rowGlue
*
* @param array $dataArray * @param array $dataArray
* @param string $keyValueGlue * @param string $keyValueGlue
* @param string $rowGlue * @param string $rowGlue
* @return string * @return string
*/ */
public static function toString(array $dataArray, $keyValueGlue = '=', $rowGlue = '&') { public static function toString(array $dataArray, $keyValueGlue = '=', $rowGlue = '&', $encloseValue = '') {
$dataString = ''; $dataString = '';
foreach ($dataArray as $key => $value) { foreach ($dataArray as $key => $value) {
$dataString .= $key . $keyValueGlue . $value . $rowGlue; $dataString .= $key . $keyValueGlue . $encloseValue . $value . $encloseValue . $rowGlue;
} }
$glueLength = strlen($rowGlue); $glueLength = strlen($rowGlue);
...@@ -86,4 +92,5 @@ class OnArray { ...@@ -86,4 +92,5 @@ class OnArray {
} }
return $result; return $result;
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment