Bug #79436 [Com]: Declaring Array Index

From: Date: Mon, 30 Mar 2020 19:39:06 +0000
Subject: Bug #79436 [Com]: Declaring Array Index
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226352@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79436&edit=1 ID: 79436 Comment by: schmidtzilla at outlook dot com Reported by: schmidtzilla at outlook dot com Summary: Declaring Array Index Status: Not a bug Type: Bug Package: *General Issues Operating System: LINUX cpanel PHP Version: 7.2.29 Block user comment: N Private report: N New Comment: You are correct. When I inserted into database I didn't quote the variable and it somehow game me an unexpected result of 25. Previous Comments: ------------------------------------------------------------------------ [2020-03-30 19:26:06] schmidtzilla at outlook dot com If this is not a bug how would you go about assigning the value 'Speed' into the index 'type' without receiving the indexs value of 25? ------------------------------------------------------------------------ [2020-03-30 19:19:53] requinix@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. https://3v4l.org/kDjTA ------------------------------------------------------------------------ [2020-03-30 19:15:05] schmidtzilla at outlook dot com Description: ------------ $round = [ 'round' => empty($current) ? 1 : $current['round'] + 3, 'type' => 'Public', 'starts' => empty($current) ? $_SERVER['REQUEST_TIME'] : floor($_SERVER['REQUEST_TIME'] / 86400) * 86400 + 72000, 'ends' => floor($_SERVER['REQUEST_TIME'] / 86400) * 86400 + 72000 + 864000, 'speed' => 25, 'build' => 2500, 'credits' => 4294967295, 'jackpot' => 100 ]; lLater on in code.. $round = [ 'round' => $current['round'] + 1, 'type' => 'Speed', 'starts' => floor($_SERVER['REQUEST_TIME'] / 86400) * 86400 + 72000, 'ends' => floor($_SERVER['REQUEST_TIME'] / 86400) * 86400 + 72000 + 172800, 'speed' => 100, 'build' => 2500, 'credits' => 0, 'jackpot' => 50 ]; If the same variable is already assigned with different values 'type' => 'Speed' now equals 25 because it's now assuming I am calling onto the variable $round['speed'] instead of wanting the string 'Speed' and inputs it into its place. Expected result: ---------------- I expect the $round = [ 'type' => 'Speed' ] to put the string Speed into the index 'type' of the $round variable instead of the value of $round['speed'] Actual result: -------------- $round['type] = 25; instead of $round['type'] = 'Speed'; ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79436&edit=1

« previous php.bugs (#226352) next »