PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 260917
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v260917
260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 All 189 releases
← All changes | src/includes/classes/utils-arrays.inc.php +22 -0 260814260917 View file →
@@ -160,8 +160,30 @@
160 160 }
161 161 return $array;
162 162 }
163 163 /**
164 + * Sets specified array elements to an empty string when they are not set according to ``isset()`` (missing or NULL).
165 + *
166 + * @package s2Member\Utilities
167 + * @since 260814
168 + *
169 + * @param array $array An input array.
170 + * @param array $keys Array keys whose unset elements should be set.
171 + * @return array Returns the ``$array`` after setting unset elements to empty strings.
172 + */
173 + public static function set_unset_elements ($array = FALSE, $keys = FALSE)
174 + {
175 + $array = (array)$array;
176 + $keys = (array)$keys;
177 +
178 + //260814 isset() treats both missing keys and null values as unset; initialize either case to an empty string.
179 + foreach ($keys as $key)
180 + if (!isset($array[$key]))
181 + $array[$key] = '';
182 +
183 + return $array;
184 + }
185 + /**
164 186 * Forces string values on each array value *(also supports multi-dimensional arrays)*.
165 187 *
166 188 * @package s2Member\Utilities
167 189 * @since 111101