Bug #77286 [Opn->Nab]: The array key like '123' Not a string?
| From: | requinix@php.net | Date: | Wed, 12 Dec 2018 04:15:09 +0000 |
| Subject: | Bug #77286 [Opn->Nab]: The array key like '123' Not a string? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218404@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
Updated by: requinix@php.net
Reported by: xpigeon at 163 dot com
Summary: The array key like '123' Not a string?
-Status: Open
+Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: Windows 7
PHP Version: 7.3.0
Block user comment: N
Private report: N
New Comment:
http://php.net/manual/zh/language.types.array.php
>
> å
嫿忳æ´åå¼çå符串ä¼è¢«è½¬æ¢ä¸ºæ´åãä¾å¦é®å
> "8" å®é
ä¼è¢«å¨å为 8ã使¯ "08"
> åä¸ä¼å¼ºå¶è½¬æ¢ï¼å 为å
¶ä¸æ¯ä¸ä¸ªåæ³çåè¿å¶æ°å¼ã
var_dump($key) -> int(123), int(456), int(789), string(3) "abc", string(3)
"xyz"
Previous Comments:
------------------------------------------------------------------------
[2018-12-12 04:10:17] xpigeon at 163 dot com
This line will Annotatedï¼
```
if(strstr($value,"$key")){ // is OK
```
-=> Edit as
```
//if(strstr($value,"$key")){ // is OK
```
------------------------------------------------------------------------
[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