note 18925 modified in function.array-search by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:49:24 +0000 |
| Subject: | note 18925 modified in function.array-search by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-79983@lists.php.net to get a copy of this message | ||
Note to the previous post:
<?php
$map = array( 'version' => 4
, 'OS' => 'Linux'
, 'lang' => 'english'
, 'short_tags' => true
);
$key = array_search("4",$map);
print $key;
//returns short_tags
//strange results..
$array = array (1,13, 20);
$key = array_search("13",$array);
print $key;
//works as expected
//returns 1
?>
If you put the number in quotes it searches for the array number. Try it without the quotes.
--was--
Note to the previous post:
$map = array( 'version' => 4
, 'OS' => 'Linux'
, 'lang' => 'english'
, 'short_tags' => true
);
$key = array_search("4",$map);
print $key;
//returns short_tags
//strange results..
$array = array (1,13, 20);
$key = array_search("13",$array);
print $key;
//works as expected
//returns 1
If you put the number in quotes it searches for the array number. Try it without the quotes.
http://php.net/manual/en/function.array-search.php