in_array()

By Benoit Asselin on Oct 24, 2007

General

This snippet searches an array for a pre-specified element and returns ‘true’ if it’s found, ‘false’ if it’s not found. It functions like the in_array() in PHP.


Notes

Usage example:

var v_array = [ 5, 10, 15, 20, 25];
document.writeln(v_array.in_array(10)); // will return true
document.writeln(v_array.in_array(11)); // will return false

Source Code

Paste this source code into the designated areas.

Head

Paste this code into your script.