function display_str($Str) { if ($Str != '') { $Str = make_utf8($Str); $Str = mb_convert_encoding($Str, 'HTML-ENTITIES', 'UTF-8'); $Str = preg_replace("/&(?![A-Za-z]{0,4}\\w{2,3};|#[0-9]{2,5};)/m", '&', $Str); $Replace = array("'", '"', "<", ">", '€', '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', 'Ž', '‘', '’', '“', '”', '•', '–', '—', '˜', '™', 'š', '›', 'œ', 'ž', 'Ÿ'); $With = array(''', '"', '<', '>', '€', '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', 'Ž', '‘', '’', '“', '”', '•', '–', '—', '˜', '™', 'š', '›', 'œ', 'ž', 'Ÿ'); $Str = str_replace($Replace, $With, $Str); } return $Str; }
/** * Given an array where the order matches the fieldNames, * create an object with propertie and values. * * @param <array> $fieldNames * @param <array> $record * @return stdClass */ public function objectify($fieldNames, $record) { $obj = new stdClass(); foreach ($fieldNames as $field => $title) { if (isset($record[$title])) { $value = trim($record[$title]); $value = make_utf8($value); $value = !is_bool($value) && empty($value) ? null : $value; $obj->{$field} = $value; } } return $obj; }
public function schema_map_filter($field, $value, $schema = null) { if (is_json($value)) { $value = json_decode($value); } else { if ($field == 'keyword' | $field == 'language' | $field == 'references' | $field == 'theme' | $field == 'programCode' | $field == 'bureauCode') { $value = str_getcsv($value); } else { if ($field == 'dataQuality' && !empty($value)) { $value = (bool) $value; } } } if (is_array($value)) { $value = array_map("make_utf8", $value); $value = array_map("trim", $value); $value = array_filter($value); // removes any empty elements in an array $value = array_values($value); // ensures array_filter doesn't create an associative array } else { if (is_string($value)) { $value = trim($value); $value = make_utf8($value); } } $value = !is_bool($value) && empty($value) ? null : $value; return $value; }