1
2<?php
3$array = array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');
4
5$key = array_search('green', $array); // $key = 2;
6$key = array_search('red', $array); // $key = 1;
7?>
8
9
1// array demo
2
3public $gender = array(
4 1 => 'Male',
5 2 => 'Female',
6 3 => 'Other',
7);
8
9$gen = 1;
10
11if ($gen == array_search('Male', $this->gender)) {
12 $gender = __d('member', 'male');
13
14} elseif ($gen == array_search('Female', $this->gender)) {
15 $gender = __d('member', 'female');
16
17}
18
19