dozent_array_to_in_sql( array $array = array() )

Array value to where in sql format


Description

Some time we need to perform mysql query IN() or not IN(), it’s tough to convert an array to in format This function convert array to in sql format

Example usage:

$status = dozent_array_to_in_sql( [ 'publish', 'pending' ] ); // 'publish','pending'

Parameters

$array

(array) (Optional) Input Array

Default value: array()


Return

(string)


Source

File: includes/core-functions.php

	function dozent_array_to_in_sql( $array = [] ) {
		$in_sql = "";

		$array = (array) $array;
		$array = array_filter( $array );

		if ( dozent_count( $array ) ) {
			$in_sql = "'" . implode( "','", $array ) . "'";
		}

		return $in_sql;
	}


Changelog

Changelog
Version Description
DozentLMS 1.0.0 Introduced.