]> git.mxchange.org Git - mailer.git/blobdiff - inc/wrapper-functions.php
Rewrote 2 str_replace() calls to one with array()
[mailer.git] / inc / wrapper-functions.php
index 135f3d3dc45e79ed04ef8b9dc863c9536b0b0890..e20a4abd2139350827cf4f5e69ec2794cb233cc5 100644 (file)
@@ -3556,5 +3556,27 @@ function ifSubjectHasReferralSuffix ($subject) {
        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]
 ?>