All Questions
1,349 questions
-7
votes
2
answers
87
views
Filter an array of arrays to remove rows where the entire payload is found inside another (potentially larger) row [closed]
I get an array of associative arrays of selected company's hierarchy combinations (Some hierarchy levels may be null).
For example, if the hierarchy goes division > department > team:
[
0 =>...
-4
votes
1
answer
133
views
Building nested array with foreach [closed]
I am trying to build an associative multidimensional array like this:
array(
[0] => Array(
Parent => Mr Smith,
Children => array(
Firstmane => Bob,
...
1
vote
4
answers
100
views
Use flat array's values to generate an associative array whose keys and values are given a static prefix
Is there a shorthand for the following code:
$result = array_combine(
array_map(fn($elem) => "key_$elem", $array),
array_map(fn($elem) => "value_$elem", $array)
);
...
0
votes
2
answers
68
views
Map values between two arrays to generate a flat, associative array
I have two arrays, one is a list of status IDs and the corresponding numbers of records that are that status ID. The second array is the names of the statuses. I'd like to tie them together so I have ...
-1
votes
1
answer
52
views
Change an array to an associative array in php to get key value pairs accordingly [duplicate]
I have a php script that returns the images(or files) in a directory. The final output is a json of file names.
Below is the code of of what I have now and the result.
<?php
$files = array();
$...
1
vote
1
answer
135
views
how to create array with associative array in other array php [duplicate]
I´m trying to create this structure to send data to API
$metaDataList = [
[
"key" => "item_description0",
"value" =&...
0
votes
4
answers
129
views
Remove key value pairs from an nested associative array where the value is null or " " or [] [duplicate]
I've the following array:
$variables = [
"id" => "discountCodeID",
"test" => null,
"codeDiscount" => [
"code" => "...
0
votes
3
answers
83
views
Unable to convert indexed array to associative array in php
The array $digit now has data in this form :
'numbers' =>
array (
0 => '1,2,3',
)
But I need that array in the below shown form:
'numbers' =>
array (
0 => 1,
1 => 2,...
0
votes
2
answers
41
views
Append an array with an array without any overwriting
I'm trying to create an array that looks like below.
$arr = array(
'post_type' => 'smart_contract',
'post_status' => 'publish',
'author' => $user_id,
'...
1
vote
1
answer
184
views
php reading kodi/xbmc movie nfo files
I am working on a php script to parse the movie nfo and tv nfo files that kodi generates/uses.
However I have problems with getting some of the children properties (not sure if this is the correct ...
0
votes
4
answers
94
views
Get key (not index) from qualifying row in an associative array of associative arrays
Here my array:
$array = [
'key1' => [
'first' => 'azerty',
'second' => 'qwerty'
],
'key2' => [
'first' => 'hello',
'second' => 'world'
...
1
vote
2
answers
65
views
Transpose a multidimensional array with variable depth (2 levels and 3 levels)
I need to restructure an array containing data in 2 levels and 3 levels. All of the values should be grouped by their indexes, but I need to maintain associative relationships.
Sample input:
$...
0
votes
0
answers
48
views
replace associative array of one file to another file index array
I have two files ConfigAuthGroups.php and AuthGroups.php in ConfigAuthGroups.php file have index array and AuthGroups.php have associative array, i want to replace associative array with index array.
...
0
votes
1
answer
73
views
Use subarray data from json to create rows of associative arrays
I want to map my JSON response to specific array construction.
Here is my JSON data in short:
"code": 200,
"unit": null,
"data": [
{
"2022-11-16": ...
1
vote
2
answers
82
views
Parse a multi-line block of delimited text to create an array of associative rows
I am getting a multi-line block of text from the single column of a database query result set like this:
$data = <<<DATA
DATE = FEE = PAYMENT
2021-03-09 = 119.25 = 119.25 = 2021-04-13
...