function fp_explode_assoc

7.x misc.inc fp_explode_assoc($string, $delim = ",", $assign_sep = "_S-")
6.x misc.inc fp_explode_assoc($string, $delim = ",", $assign_sep = "_S-")
5.x misc.inc fp_explode_assoc($string, $delim = ",", $assign_sep = "-")

Takes a string (created by fp_join_assoc()) and re-creates the 1 dimensional assoc array.

The separator is meant to be a string extremely unlikely to be used in the key or values.

See also

fp_join_assoc()

1 call to fp_explode_assoc()
Course::load_course_from_data_string in classes/Course.php
This will take a data string, as created by the function to_data_string(), and make $this object match the original object. It is a poor man's unserialize. See to_data_string()'s description for a fuller picture of what is going on.

File

includes/misc.inc, line 1896
This file contains misc functions for FlightPath

Code

function fp_explode_assoc($string, $delim = ",", $assign_sep = "_S-") {
  $rtn = array();

  $temp = explode($delim, $string);
  foreach ($temp as $line) {
    $line = trim($line);
    if ($line == "") {
      continue;
    }

    $temp2 = explode($assign_sep, $line);
    if (is_numeric($temp2 [1])) {
      $temp2 [1] = $temp2 [1] * 1; // if its numeric anyway, make it have a numeric type.      
    }

    $rtn [$temp2 [0]] = $temp2 [1];

  }

  return $rtn;
}