二分法查找數組是否包含某一元素,兼容正反序,代碼實現:
<? = (int)['key' search( , = ()-1 = 0 = [] < [ ( = + = (int)(%2 == 1 ? (/2) : /2 ( < -1 } ( == [ 1 } ( > [ ? = +1 : = -1 } ( < [ ? = -1 : = +1 = '4', '5', '7', '8', '9', '10', '11', '12' search(, ( search(, );
這個沒考慮非順序鍵的數組,主要是方法,如果需要大家可以自己擴展下。