PHP: array_search - Manual in Deutsh
PHP: array_search - Manual in French
PHP: array_search - Manual in Polish

You Are At PHP: array_search - Manual Area


recent searches:
include functions , variable functions , post functions...




If you are new to PHP or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to create a simple PHP website.

PHP is a reflective programming language originally designed for producing dynamic web pages.[1] PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

PHP Manual
PrevNext

array_search

(PHP 4 >= 4.0.5, PHP 5)

array_search -- Searches the array for a given value and returns the corresponding key if successful

Description

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

Searches haystack for needle and returns the key if it is found in the array, FALSE otherwise.

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

Note: Prior to PHP 4.2.0, array_search() returns NULL on failure instead of FALSE.

If the optional third parameter strict is set to TRUE then the array_search() will also check the types of the needle in the haystack.

If needle is found in haystack more than once, the first matching key is returned. To return the keys for all matching values, use array_keys() with the optional search_value parameter instead.

Example 1. array_search() example

<?php
$array
= array(0 => 'blue', 1 => 'red', 2 => 'green', 3 => 'red');

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

Warning

This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE, such as 0 or "". Please read the section on Booleans for more information. Use the === operator for testing the return value of this function.

See also array_keys(), array_values(), array_key_exists(), and in_array().

klimatyzacje lg warszawa
uroda
Koszulki Smoke Story Koszulki Smoke Story
Kurs gotowania
Electro lista serwisów

Another Useful functions:


zend-macro.zend-arg-array-info | zend-api.zend-get-parameters-array | zend-api.zend-get-parameters-array-ex | zend-api.zend-copy-parameters-array | zend-api.init-op-array | zend-api.destroy-op-array | zend-api.array-init | ref.array | language.types.array | language.operators.array | function.udm-alloc-agent-array | function.sybase-fetch-array | function.sqlite-fetch-array | function.sqlite-array-query | function.sesam-field-array | function.sesam-fetch-array | function.pg-fetch-array | function.odbc-fetch-array | function.oci-fetch-array | function.oci-bind-array-by-name | function.mysqli-fetch-array | function.mysql-fetch-array | function.mssql-fetch-array | function.msql-fetch-array | function.msession-set-array | function.msession-get-array | function.maxdb-fetch-array | function.iterator-to-array | function.is-array | function.ingres-fetch-array | function.in-array | function.hw-objrec2array | function.hw-array2objrec | function.httpquerystring-toarray | function.filter-var-array | function.filter-input-array | function.fbsql-fetch-array | function.db2-fetch-array | function.curl-setopt-array | function.call-user-method-array | function.call-user-func-array | function.arrayobject-offsetunset | function.arrayobject-offsetset | function.arrayobject-offsetget | function.arrayobject-offsetexists | function.arrayobject-getiterator | function.arrayobject-count | function.arrayobject-construct | function.arrayobject-append | function.arrayiterator-valid | function.arrayiterator-seek | function.arrayiterator-rewind | function.arrayiterator-next | function.arrayiterator-key | function.arrayiterator-current | function.array | function.array-walk | function.array-walk-recursive | function.array-values | function.array-unshift | function.array-unique | function.array-uintersect | function.array-uintersect-uassoc | function.array-uintersect-assoc | function.array-udiff | function.array-udiff-uassoc | function.array-udiff-assoc | function.array-sum | function.array-splice | function.array-slice | function.array-shift | function.array-search | function.array-reverse | function.array-reduce | function.array-rand | function.array-push | function.array-product | function.array-pop | function.array-pad | function.array-multisort | function.array-merge | function.array-merge-recursive | function.array-map | function.array-keys | function.array-key-exists | function.array-intersect | function.array-intersect-ukey | function.array-intersect-uassoc | function.array-intersect-key | function.array-intersect-assoc | function.array-flip | function.array-filter | function.array-fill | function.array-fill-keys | function.array-diff | function.array-diff-ukey | function.array-diff-uassoc | function.array-diff-key | function.array-diff-assoc | function.array-count-values | function.array-combine | function.array-chunk | function.array-change-key-case |


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.