Skip to main content
0 votes
2 answers
71 views

PHPstan making bad assumption about array key

PHPstan seems to incorrectly narrow type after if (empty(...)). \PHPStan\dumpType($_GET); // array<mixed> if (empty($_GET['ssid'])) { /* do nothing */ } \PHPStan\dumpType($_GET); // non-...
Roman Hocke's user avatar
  • 4,251
0 votes
1 answer
57 views

How to get the current key name while building an array

I am building a PHP menu and I want to have an array used to define the menu items. The array would be something like this: $menuItems = [ "menu_title" => [ "view_type&...
George M.'s user avatar
1 vote
1 answer
60 views

how to use string to be key of array in php

I have array that need to call. $array['first_key']['second_key'] = 'value'; $keys = "['first_key']['second_key']"; I want to call it $array.$key that like $array['first_key']['second_key']. ...
Rahmat Hidayat's user avatar
0 votes
0 answers
31 views

Is it possible not add a fields of id_user in my html structure. that id_user serve as my foreign key and it says I have an undefined array key error

Undefined Array Key about id_user expecting to automatically add the id in my attributes, id_user without adding any field of html structure and without an error and proceed to another operation of ...
Noli Baluyot's user avatar
0 votes
1 answer
6k views

Warning: Undefined array key 1

It only started giving me problems when i upgraded to php 8.1. The issue is on the line $time = $matches Although, this is a very generic question and probably has been answered quite a few time ...
Singleton's user avatar
  • 133
2 votes
1 answer
3k views

Undefined array key "REQUEST_URI" php warning - MVC does not return query string

I am creating an MVC framework with PHP. I am not able to get the query string. The following code does not return the query string index.php <?php /** * Front controller * * PHP version 5.4 */...
Dodee's user avatar
  • 31
0 votes
0 answers
212 views

How to rename array keys to a string value in JavaScript

I have an array that conatins a list of objects, then am mapping through the object to display a list of data. Right now when user add item to the list , I want to change the index of that newly added ...
Ahmad Salihu's user avatar
2 votes
0 answers
42 views

Inconsistent array keys after unset + merge + add value, versions 7.3 & 7.4

Code example: <?php $values = []; // start values $list = ['one', 'two', 'three']; // some list $oneMore = 'four'; // some element unset($list[...
L.E.'s user avatar
  • 21
0 votes
0 answers
239 views

Unidentified Array Key in $_GET PHP

I'm trying to create a CRUD system in PHP linked with XML that contains all the info that I want to create a CRUD system with. I'm stuck with editing the basic infos because in this code: <?php $...
user13710970's user avatar
0 votes
1 answer
39 views

Weird problem with map thru an array - key/id not recognized

I have a small array of data in a separate file. Each item of the array has an id of a unique number. In another file I declared props for the component that I want to rendex and the overall "...
user avatar
1 vote
1 answer
1k views

Generating a php array from mysql and want to use ID from db as array keys

The current output is.. Array ( [0] => Array ( [ID] => 20 [name] => Peter [datetime] => Tuesday 26th Oct 21 3:50am ) [1] => ...
Glen Keybit's user avatar
0 votes
2 answers
2k views

PHP check if array key equals to specific string value

I have an array and I want to check if the key equals to a specific string, so I can use that information and give a new value to another variable $x, depending on which key is given. So far I tried ...
strayed soul's user avatar
-3 votes
1 answer
159 views

PHP - change/adding numerical value to array key value using submit button

I am using array to limit the results from glob(), like a pagination $show = array(5,10,15,20); $directories = glob(__DIR__.'/*', GLOB_ONLYDIR); $directories = array_slice($directories, 0, $show[0]); ...
FUNDIY's user avatar
  • 1
-1 votes
1 answer
53 views

Get JSON key with PHP [duplicate]

I have a JSON that looks like this $array = '{ "de": { "name": "last_name", "label": "Last Name", "f_type": &...
lStoilov's user avatar
  • 1,351
1 vote
1 answer
106 views

Recursively extract key paths from array - excluding numeric keys

In php, I need a function to return all keys in array of objects. For arrays and objects I need keys like parentkey->key. If the key is again an array, then I need parentkey->key->key1. My ...
Rekha Sarnitha's user avatar

15 30 50 per page
1
2 3 4 5
11