LLMS_Database_Query::sanitize_id_array( mixed $ids = array() )

Sanitize input to ensure an array of absints


Description Description


Parameters Parameters

$ids

(mixed) (Optional) String/Int or array of strings/ints

Default value: array()


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/abstracts/abstract.llms.database.query.php

	protected function sanitize_id_array( $ids = array() ) {

		if ( empty( $ids ) ) {
			$ids = array();
		}

		// allow numeric strings & ints to be passed instead of an array
		if ( ! is_array( $ids ) && is_numeric( $ids ) && $ids > 0 ) {
			$ids = array( $ids );
		}

		foreach ( $ids as $key => &$id ) {
			$id = absint( $id ); // verify we have ints
			if ( $id <= 0 ) { // remove anything negative or 0
				unset( $ids[ $key ] );
			}
		}

		return $ids;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.15.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.