Bug #77286 [Opn]: The array key like '123' Not a string?
| From: | xpigeon at 163 dot com | Date: | Wed, 12 Dec 2018 04:10:17 +0000 |
| Subject: | Bug #77286 [Opn]: The array key like '123' Not a string? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218403@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77286&edit=1
ID: 77286
User updated by: xpigeon at 163 dot com
Reported by: xpigeon at 163 dot com
Summary: The array key like '123' Not a string?
Status: Open
Type: Bug
Package: *General Issues
Operating System: Windows 7
PHP Version: 7.3.0
Block user comment: N
Private report: N
New Comment:
This line will Annotatedï¼
```
if(strstr($value,"$key")){ // is OK
```
-=> Edit as
```
//if(strstr($value,"$key")){ // is OK
```
Previous Comments:
------------------------------------------------------------------------
[2018-12-12 04:07:16] xpigeon at 163 dot com
Description:
------------
In the array like this:
```
'123'=>'abc'
```
The key like '123' Not as a string?
Test script:
---------------
<?php
$value = 'mystr-abcd-1234';
$keys = ['123'=>0, '456'=>0, '789'=>0, 'abc'=>0,
'xyz'=>0];
foreach($keys as $key=>$v){
if(strstr($value,"$key")){ // is OK
if(strstr($value,$key)){ // Notice Error
$keys[$key]=1;
}
}
var_dump($keys);
die();
/*
php7.3
strstr(): Non-string needles will be interpreted as strings in the future.
Use an explicit chr() call to preserve the current behavior
*/
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77286&edit=1