#33333 [Opn->Fbk]: strpos (and other functions) not seeing a character that is very clearly there

From: Date: Tue, 14 Jun 2005 06:45:22 +0000
Subject: #33333 [Opn->Fbk]: strpos (and other functions) not seeing a character that is very clearly there
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-80287@lists.php.net to get a copy of this message
ID: 33333 Updated by: rasmus@php.net Reported By: FxChiP at Gmail dot com -Status: Open +Status: Feedback Bug Type: Strings related Operating System: *nix most likely PHP Version: 4.3.11 New Comment: Nice bug # For reports like this, you really need to provide the od -c or od -x output of both the relevant bits of the script file and the input file. I think you will find that what is in the file and what is in the script are two different things that whatever you are using to view both just happen to look similar. Just because two things look similar does not mean that it is the same byte sequence behind them. Previous Comments: ------------------------------------------------------------------------ [2005-06-14 07:50:01] FxChiP at Gmail dot com Description: ------------ Using explode(), strpos(), and probably any other string-related function in conjunction with a string returned from fgets() will (at least sometimes) produce an incorrect result. i.e. if there is a line like this in a file called public_covers.db: FxChiP§this is a test statement§guitar§akczf.pk.gif§whee§1113865622§1113967262 The *entire string* will be the first element in the array created by explode(). More information is included in the reproduce code. Contents of the public_covers.db file: FxChiP§this is a test statement§guitar§akczf.pk.gif§whee§1113865622§1113967262 duality515§Vermilion Pt2§bass§jimroot54_vermilionpt2.mp3§pwnage§1113877848§1113967262 duality515§Everything Ends§guitar§macca_everythingends.mp3§w00t§1113967262§1113967262 duality515§gsg§bass§temp.jpg§§1116469075§1113967262 Reproduce code: --------------- <?PHP $public_db = fopen("public_covers.db", "r"); $bwerp = explode('§', fgets($public_db)); var_dump($bwerp); ?> Expected result: ---------------- From the var_dump, I'd expect to see an array consisting of everything "in between" the § characters. Actual result: -------------- array(1) { [0]=> string(84) "FxChiP§this is a test statement§guitar§akczf.pk.gif§whee§1113865622§1113967262 " } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33333&edit=1

« previous php.bugs (#80287) next »