X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Fwrapper-functions.php;h=e20a4abd2139350827cf4f5e69ec2794cb233cc5;hp=135f3d3dc45e79ed04ef8b9dc863c9536b0b0890;hb=87229cb5d7b5396793e85fd0b4172d473195835c;hpb=a00ad7dd8c36a5322e28f38d8d641efb90c00c92 diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 135f3d3dc4..e20a4abd21 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -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] ?>