|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-03-18 19:03 UTC] gorivo at gmail dot com
Description: ------------ It seems array_search() is not working... Reproduce code: --------------- URL to PHP code: http://www.huntexpired.com/gorivo/array_search.phps Expected result: ---------------- 504 ( the array key of "0e0" ) Actual result: -------------- 0 ( FALSE ) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 14:00:01 2025 UTC |
Ok, Tony, I found a way how to shorten my code. Here it is: <?php for($x=0; $x!=10; $x++) $symbols[] = $x; for($x='a'; $x!='aa'; $x++) $symbols[] = $x; foreach( $symbols as $v1 ) foreach( $symbols as $v2 ) foreach( $symbols as $v3 ) $arr[] = $v1.$v2.$v3; # WORKS!: (returns 13368 as expected) echo 'key for "abc": '.array_search('abc', $arr).'<br />'; # DOESN`T WORK!: (should return 504, but doesn't) echo 'key for "0e0": '.array_search('0e0', $arr).'<br />'; ?> The script above generates all possible 3-char combinations from numbers and letters (from 000 to zzz) and saves them to $arr. Everything is ok, except that array_search is not working for values from '0e0' to '0e9'. That's the problem. I hope you understood me :) Working script: http://www.huntexpired.com/gorivo/array_search.php Source code: http://www.huntexpired.com/gorivo/array_search.phps