php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25909 strpos
Submitted: 2003-10-19 06:29 UTC Modified: 2003-10-19 07:50 UTC
From: zygimantas at skylords dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.2 OS: RH7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zygimantas at skylords dot com
New email:
PHP Version: OS:

 

 [2003-10-19 06:29 UTC] zygimantas at skylords dot com
Description:
------------
strpos fails when array is used as needle.



Reproduce code:
---------------
$i = 2;
$str_word = 'sentence with word2';
$arr_letters = array('word1', 'word2', 'word3');

echo strpos($str_word, $arr_letters[$i]);

Expected result:
----------------
null


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-19 07:50 UTC] sniper@php.net
The function works properly when it returns 'false' as the haystack string does not contain string 'word3' in it.

Hint: Array indices start from 0 (zero).

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 12:01:33 2025 UTC