How to check if one one string contains another string in Javascript

To check if one one string contains another string in Javascript you can use the following method.

Sample JS

if(testString.indexOf("substring") > -1){
}

Please rate this snippet

How to check if array contains string case insensitive in PHP

To check if array contains string case insensitive in PHP you can use the following snippet.

function ArrayContainsStringCaseInsensitve($searchString, $array){
    foreach($array as $element){
        if(strcasecmp($searchString, $element)==0){
            return true;
        }
    }
    return false;
}

Please rate this snippet

How to check if a folder contains files in C# and VB.NET

To check if a folder contains files in C# and VB.NET you can use the following snippet below.

Sample C#

public static Boolean HasFilesInFolder(DirectoryInfo directory, string paramFilter)
{
	try
	{
		return directory.GetFiles(paramFilter).Any();
	}
	catch (Exception ex)
	{
		//handle the exception your way
		return false;
	}
}

Sample VB.NET

Public Shared Function HasFilesInFolder(directory As DirectoryInfo, paramFilter As String) As [Boolean]
	Try
		Return directory.GetFiles(paramFilter).Any()
	Catch ex As Exception
		'handle the exception your way
		Return False
	End Try
End Function

Please rate this snippet