X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FArray.php;h=5ecdb554d58b29b404cecba3f84c0c40ff8caf90;hb=ef84a7da1da67fa6b68f3dd51af5a6d8c77a06d4;hp=1a3d8a002072b1cab93d60e1a9bf724d69bb6718;hpb=2d82d5a2151b9e9ac865f223521836ea4d530566;p=civicrm-core.git diff --git a/CRM/Utils/Array.php b/CRM/Utils/Array.php index 1a3d8a0020..5ecdb554d5 100644 --- a/CRM/Utils/Array.php +++ b/CRM/Utils/Array.php @@ -119,26 +119,26 @@ class CRM_Utils_Array { * The array to be serialized. * @param int $depth * (optional) Indentation depth counter. - * @param string $seperator + * @param string $separator * (optional) String to be appended after open/close tags. * * @return string * XML fragment representing $list. */ - public static function &xml(&$list, $depth = 1, $seperator = "\n") { + public static function &xml(&$list, $depth = 1, $separator = "\n") { $xml = ''; foreach ($list as $name => $value) { $xml .= str_repeat(' ', $depth * 4); if (is_array($value)) { - $xml .= "<{$name}>{$seperator}"; - $xml .= self::xml($value, $depth + 1, $seperator); + $xml .= "<{$name}>{$separator}"; + $xml .= self::xml($value, $depth + 1, $separator); $xml .= str_repeat(' ', $depth * 4); - $xml .= "{$seperator}"; + $xml .= "{$separator}"; } else { // make sure we escape value $value = self::escapeXML($value); - $xml .= "<{$name}>$value{$seperator}"; + $xml .= "<{$name}>$value{$separator}"; } } return $xml; @@ -218,14 +218,14 @@ class CRM_Utils_Array { * Destination array. * @param string $prefix * (optional) String to prepend to keys. - * @param string $seperator + * @param string $separator * (optional) String that separates the concatenated keys. */ - public static function flatten(&$list, &$flat, $prefix = '', $seperator = ".") { + public static function flatten(&$list, &$flat, $prefix = '', $separator = ".") { foreach ($list as $name => $value) { - $newPrefix = ($prefix) ? $prefix . $seperator . $name : $name; + $newPrefix = ($prefix) ? $prefix . $separator . $name : $name; if (is_array($value)) { - self::flatten($value, $flat, $newPrefix, $seperator); + self::flatten($value, $flat, $newPrefix, $separator); } else { $flat[$newPrefix] = $value; @@ -569,10 +569,10 @@ class CRM_Utils_Array { $node = &$result; foreach ($keys as $key) { if (is_array($record)) { - $keyvalue = isset($record[$key]) ? $record[$key] : NULL; + $keyvalue = $record[$key] ?? NULL; } else { - $keyvalue = isset($record->{$key}) ? $record->{$key} : NULL; + $keyvalue = $record->{$key} ?? NULL; } if (isset($node[$keyvalue]) && !is_array($node[$keyvalue])) { $node[$keyvalue] = []; @@ -915,7 +915,7 @@ class CRM_Utils_Array { foreach ($matrix as $pos => $oldRow) { $newRow = []; foreach ($columns as $column) { - $newRow[$column] = CRM_Utils_Array::value($column, $oldRow); + $newRow[$column] = $oldRow[$column] ?? NULL; } $newRows[$pos] = $newRow; }