noptin_parse_list( array|string $list, bool $strict = false )

Converts a comma- or space-separated list of scalar values into an array.


Parameters Parameters

$list

(array|string) (Required) List of values.

$strict

(bool) (Optional) Whether to only split on commas.

Default value: false


Top ↑

Return Return

(array) Sanitized array of values.


Top ↑

Source Source

File: includes/functions.php

function noptin_parse_list( $list, $strict = false ) {

	if ( ! is_array( $list ) ) {

		if ( $strict ) {
			$list = preg_split( '/,+/', $list, -1, PREG_SPLIT_NO_EMPTY );
		} else {
			$list = preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
		}

	}

	return map_deep( $list, 'trim' );
}


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.2.3Introduced.

Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation