Anonymous user / 18.222.69.152 Log In Register
?
Wallet: 3.00
Daily Credits:
1.20 / 1.20

PHP Functions Online


array_search

(PHP 4 >= 4.0.5, PHP 5)

array_searchSearches the array for a given value and returns the corresponding key if successful

mixed array_search(mixed $needle , array $haystack[, bool $strict = false])

Checkout ? #

Item Description Item Price Your Price
Total

Preview #

${{ variable.param.name }} = {{ variable.param|getValue:variable.form:true }};
{{ call.result}} = ;

Description #

mixed array_search ( mixed $needle , array $haystack [, bool $strict = false ] )

Searches haystack for needle.

Parameters #

needle

The searched value.

Note:

If needle is a string, the comparison is done in a case-sensitive manner.

haystack

The array.

strict

If the third parameter strict is set to TRUE then the array_search() function will search for identical elements in the haystack. This means it will also check the types of the needle in the haystack, and objects must be the same instance.

Return Values #

Returns the key for needle if it is found in the array, FALSE otherwise.

Examples #

Example #1 array_search() example

<?php
$array 
= array(=> 'blue'=> 'red'=> 'green'=> 'red');

$key array_search('green'$array); // $key = 2;
$key array_search('red'$array);   // $key = 1;
?>

Changelog #

Version Description
5.3.0 As with all internal PHP functions as of 5.3.0, array_search() returns NULL if invalid parameters are passed to it.
4.2.0 Prior to PHP 4.2.0, array_search() returns NULL on failure instead of FALSE.

See Also #