array_search : Searches the array for a given value and returns the first corresponding key if successful
array_search(array, needle);
This function searches in the array and try to find a desired value and it returns its corresponding index key.
Form 1:
a = ["t","a",1]; a.array_search("a");
Form 2:
a = ["t","a",1]; array_search(a, 1);
This function returns the array index key starting from 0 if found;otherwise, it returns -1.
a = [1, 2, “3”]; a.array_search(1);//return 0 a.array_search(2);//return 1 a.array_search(3);//return -1 a.array_search(4);//return -1 b = []; b.array_search(1);//return -1
Written by Pierre Laplante, <laplante@sednove.com>
Available from version 5.95
Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
1.0 2014-09-09 21:24:14 laplante@sednove.com