function fp_join_assoc
Search API
7.x misc.inc | fp_join_assoc($arr, $glue = ",", $assign_sep = "_S-") |
6.x misc.inc | fp_join_assoc($arr, $glue = ",", $assign_sep = "_S-") |
5.x misc.inc | fp_join_assoc($arr, $glue = ",", $assign_sep = "-") |
This function will create a string from a 1 dimensional assoc array. Ex: arr = array("pet" => "dog", "name" => "Rex") will return: pet_S-dog,name_S-Rex under the default settings.
The separator is meant to be a string extremely unlikely to be used in the key or values.
Use the fp_explode_assoc function to piece it back together.
See also
fp_explode_assoc
1 call to fp_join_assoc()
- Course::to_data_string in classes/
Course.php - This function will create a "data string" of the course. Think of it as a poor man's serialize. I can't actually use serialize, as I have to call this for every course on the screen, and the page load time was too long when using…
File
- includes/
misc.inc, line 1876 - This file contains misc functions for FlightPath
Code
function fp_join_assoc($arr, $glue = ",", $assign_sep = "_S-") {
$rtn = "";
foreach ($arr as $key => $val) {
$rtn .= $key . $assign_sep . $val . $glue;
}
// Should be an extra glue character at the end we need to trim off.
$rtn = rtrim($rtn, $glue);
return $rtn;
}