Function Reference: geodir_countries_search_sql

Summary

Returns countries search SQL.

Package

GeoDirectory_Location_Manager

Parameters

$search
(string) (required) Search string.

Default: None
$array
(bool) (required) Return as array?.

Default: false

Return Values

(array|string)
  • Search SQL.

Change Log

Since: 1.0.0

Source File

geodir_countries_search_sql() is located in geodir_location_manager/geodir_location_functions.php [Line: 2699]

Source Code

function geodir_countries_search_sql( $search = '', $array = false ) {
	$countries = geodir_get_countries_array();
	$return = $array ? array() : '';

	$search = strtolower( trim( $search ) );
	if( $search == '' ) {
		return $return;
	}

	if( !empty( $countries ) ) {
		foreach( $countries as $row => $value ) {
			$strfind = strtolower( $value );

			if( $row != $value && strpos( $strfind, $search ) === 0 ) {
				$return[] = $row;
			}
		}
	}
	if( $array ) {
		return $return;
	}
	$return = !empty( $return ) ? implode( ",", $return ) : '';
	return $return;
}