// Wrapper for str_pad() with left padding zeros
function padLeftZero ($str, $amount = 2) {
// Is str_pad() there?
- if (function_exists('str_pad')) {
+ if (!function_exists('str_pad')) {
// Use prependZeros()
return prependZeros($str, $amount);
} else {
return $GLOBALS[__FUNCTION__][$subject];
}
+// Converts an API response to an associative array
+function convertApiResponseToArray ($responseString, $keyDelimiter, $valueDelimiter) {
+ // Explode for key delimiter
+ $keys = explode($keyDelimiter, $responseString);
+
+ // Init returned array and "walk" through all entries
+ $returned = array();
+ foreach ($keys as $keyValue) {
+ // Explode it
+ $parts = explode($valueDelimiter, $keyValue);
+
+ // Count must be 2
+ assert(count($parts) == 2);
+
+ // Then add both: 0=key, 1=value
+ $returned[sqlEscapeString($parts[0])] = sqlEscapeString($parts[1]);
+ } // END - if
+
+ // Return finished array
+ return $returned;
+}
+
// [EOF]
?>