rossriley / php-scalar-objects

Experimental API for PHP Scalar Objects
70 stars 6 forks source link

Array.has/indexOf #3

Closed eborden closed 10 years ago

eborden commented 10 years ago

Array.indexOf(elem); a -> int | string | false

$a = ['a', 'b', 'c'];
$a->indexOf('a'); //0
$a->indexOf('c'); //2
$a->indexOf('d'); //false

$a = ['a' => 1, 'b' => 2, 'c' => 3];
$a->indexOf(2); //'b'

Array.has(elem); a -> bool

$a = ['a', 'b', 'c'];
$a->indexOf('a'); //true
$a->indexOf('d'); //false
rossriley commented 10 years ago

implemented with: https://github.com/rossriley/php-scalar-objects/commit/91563c676fc4785c2dd886ffee5161d89fa9ecc3

And: https://github.com/rossriley/php-scalar-objects/commit/fcdfdc630e84eccd8c68593993aa5b47d0ccf8cb