#28130 [Opn->Bgs]: array_search doesn't work with file

From: Date: Fri, 23 Apr 2004 19:48:10 +0000
Subject: #28130 [Opn->Bgs]: array_search doesn't work with file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-58678@lists.php.net to get a copy of this message
ID: 28130 Updated by: pollita@php.net Reported By: edschouten at il dot fontys dot nl -Status: Open +Status: Bogus Bug Type: Unknown/Other Function Operating System: Gentoo Linux PHP Version: 4.3.6 New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PHP. file() also returns the line endings, try searching for "2\n" or "2\r\n" (depending on your file encoding). Previous Comments: ------------------------------------------------------------------------ [2004-04-23 20:38:51] edschouten at il dot fontys dot nl Description: ------------ The array_search function works fine when searching through regular arrays, but when you try to search with it from an array made with file(), it doesn't find anything. Reproduce code: --------------- example.list: 1 2 3 4 5 bug.php: <? $list = file('example.list'); print array_search('2', $list); ?> Expected result: ---------------- 1 Actual result: -------------- <nothing> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28130&edit=1

« previous php.bugs (#58678) next »