You are here

function swftools_parse_str in SWF Tools 6.3

Parses a string passed to the input filter in to separate key value pairs.

We cannot automatically use parse_str() because things like the list of files are not key-value pairs, but just a list of items.

Parameters

string $string: The string to parse.

Return value

array An array of key/value pairs.

1 call to swftools_parse_str()
_swftools_filter_process_text in ./swftools.module
Processes text obtained from the input filter.

File

./swftools.module, line 1210
The primary component of SWF Tools that enables comprehensive media handling.

Code

function swftools_parse_str($string) {

  // Initialise the array
  $return = array();

  // Split the string at each &
  $pairs = split('&', $string);

  // Iterate over each piece
  foreach ($pairs as $pair) {

    // Split each piece at =
    $splitpair = split('=', $pair);

    // If there was only one item, or this key is already in the array append the value
    if (!isset($splitpair[1]) || array_key_exists($splitpair[0], $return)) {
      $return[] = $splitpair[0];
    }
    else {
      $return[$splitpair[0]] = $splitpair[1];
    }
  }

  // Return the result
  return $return;
}