You are here

function notifications_array_serialize in Notifications 7

Same name and namespace in other branches
  1. 6.4 notifications.module \notifications_array_serialize()

Serialize an array ordering the keys before.

This is useful for cache indexes and signatures.

2 calls to notifications_array_serialize()
Notifications_Subscription::serialize_fields in ./notifications.subscription.inc
Order and serialize fields so we can get a unique signature for this subscription fields
notifications_url_signature in ./notifications.module
Signature for url parameters

File

./notifications.module, line 963
Notifications module

Code

function notifications_array_serialize($array) {
  if (!$array) {
    return '';
  }

  // First we sort and serialize multiple conditions
  foreach ($array as $key => $value) {
    if (is_array($value)) {
      asort($value);
      $array[$key] = implode(':', $value);
    }
  }

  // Now we sort the whole condtions array maintaining index association
  ksort($array, SORT_STRING);
  return implode(',', array_keys($array)) . '/' . implode(',', $array);
}