115 questions
0
votes
0
answers
44
views
Fatal error: Uncaught TypeError: array_column(): Argument #1 ($array) must be of type array, null given [duplicate]
I have a button
<a href="like.php?type=user&id=<?php echo $user_data['userid'] ?>">
<input id="post_button" type="button" value="Sledi <?php ...
2
votes
3
answers
187
views
Sort a 2D array by column value into recurring ascending groups of not more than N of a kind
I have an array that contains other associative arrays as its values. Each one of these "sub" arrays is mapped with key-value pairs:
$items = [
['type' => 1, 'text' => 'A'],
['...
-1
votes
1
answer
48
views
Pass column from db query result to javascript [duplicate]
I'm trying to write a SQL query to hit my WordPress database as I need some of the info for my front end. However, I'm not getting anything from it. I can see the info in the database itself, so ...
-1
votes
1
answer
87
views
how to match and add column in the multi-dimensional array in PHP
we have to multi-dimensional array and we need to check some value of every element from array 1 to array two on a specific element key.
we can use following code for handle this types of complex ...
0
votes
1
answer
34
views
How to remove duplicate values by comparing two array type column values in Postgresql?
I want to remove duplicate values by comparing two array type column values.
I want to get the result of subtracting the fruit I already ate from my favorite fruit.
But if there ara 2 apples in your ...
1
vote
1
answer
503
views
Populate a flat array of values from a column within a column of a 4-level array
I have this nested multidimensional array for orders
[
[
'created_at' => 1991,
'updated_at' => 1992,
'customer_name' => 'john doe',
'line_items' => [
...
0
votes
1
answer
21
views
json_decode array returns with missing array indexes
I am trying to build a web-gui for jaredhendrickson13/pfsense-api (https://github.com/jaredhendrickson13/pfsense-api)
Either I can't get array indexes on return or they not there.
I am using laravel8 ...
0
votes
1
answer
136
views
How to remove duplicates value of same key of multidimensional array in PHP [duplicate]
I have a multidimensional array and need to remove entries with the same values for a key.
eg.
Array
(
[0] => stdClass Object
(
[id] => 1177930857
[lat] => 24.479280471802
...
0
votes
1
answer
216
views
Use column values from one subarray as keys for anotheer subarray's values
I have an object as below,
{"metaData":[{"name":"a"},{"name":"b"}],"rows":[[1,2],[3,4],[5,6]]}
I would like to change it to
[["a"=...
1
vote
1
answer
419
views
What is PostgreSQL Array Column equivalent in Synapse SQL?
I have a table in PostgreSQL that has array column like abc_id varchar[](1) and it has data in it like {A,B,C}.
I want to create that table in Synapse SQL how can I create array columns is it possible?...
1
vote
2
answers
361
views
Matching vocabulary elements to indices from LDA Model using PySpark
I'd like to take a Spark LDA Model's term indices from the .describeTopics() output and match them to the appropriate term in the count vectorizer's vocabulary. Here is the point of friction:
terms = [...
2
votes
1
answer
2k
views
I am with problems to do a query with array column in PostgreSQL with Spring Data
Entity
I have it entity with a property that is text[]:
@Entity(name = "entityname")
@Table(name = "tablename")
@ToString
@TypeDefs({
@TypeDef(name = "jsonb", ...
1
vote
3
answers
205
views
Get column values from third level of a multidimensional array
I want to get all of the values from an array with 3 levels where the key is age. How can I extract a column of data from a three dimensional array without using a foreach() loop?
My input array:
$...
0
votes
1
answer
741
views
Extract elements from Spark array column using SparklyR "select"
I have a Spark dataframe in a SparklyR interface, and I'm trying to extract elements from an array column.
df <- copy_to(sc, data.frame(A=c(1,2),B=c(3,4))) ## BUILD DATAFRAME
dfnew <- ...
0
votes
1
answer
643
views
How To Search In Multiple Columns In Json File Array?
I have a json file with this content :
[
{
"id": "apple",
"symbol": "app",
"name": "Apple",
},
]
I Want To Search In ...
1
vote
3
answers
60
views
Populate option tags with data- attributes using a multidimensional array
I have a json file that looks something like this:
{
"world": {
"france": {
"city": {
"city_1": {
&...
0
votes
1
answer
371
views
Format number in array within an array_sum
I have a view in a laravel project where I have to print the sum of some array columns.
I Have this kind of code to achieve the result:
@foreach($data as $row)
.......
@foreach($row as $key => $...
-3
votes
1
answer
1k
views
Get column of data from third level of a multidimensional array
I have a multidimensional array with four levels of data. Here's a small sample:
$data = [
[
[
'Date' => '2021-03-15T00:00:00.0000000+01:00',
'Arena' => ['Id'...
7
votes
5
answers
615
views
How to average columns of data from multiple, flat arrays?
Let's say I have 4 arrays with the same amount of values in each:
$array1 = array(0, 7, 5, 0);
$array2 = array(2, 6, 10, 0);
$array3 = array(4, 8, 15, 10);
$array4 = array(6, 7, 20, 10);
I want to ...
2
votes
2
answers
88
views
Find value from multidimensional array from given two values
I have the following array.
Array
(
[0] => Array
(
[product] => p1
[item] => q1
[date] => d1
[status] => N
)
[1] ...
0
votes
2
answers
49
views
How can I sort IDs by multiple attributes
I have a multi-dimensional array of fencer ids with 3 attributes (see code below)
Array
(
[0] => Array
(
[id] => 5255
[ratio] => 1
[...
1
vote
1
answer
745
views
Postgres db design Normalize tables or Use Array Columns
Newbie trying to figure out the best way to design a Postgres db for the following use case scenario.
There is an Account table for the business customers and there is a contacts table with a column ...
2
votes
1
answer
125
views
How to sum up a column of an input file given to a CombiTimeTable in Modelica
I have used a .txt file (T_in1) as an input in a 2D-CombiTimeTable in Modelica. It contains an array with the size of (4,2); the first column is time and the second one is the time-dependent variable. ...
0
votes
2
answers
2k
views
PHP array_column to return with values only
Is it possible to get a result from array_column that has values only?
sample array i want to array_column
$array = [
['name' => ''],
['name' => 'John'],
['name' => 'Doe']
]
when i ...
0
votes
2
answers
416
views
Use array_column in combination with preg_match
Lets suppose we have an array of arrays that needs to be converted to rows
From this:
Array
(
[subject] => Array
(
[0] => EDN:LOC:DERR
[1] => EDN:LOC:...
2
votes
2
answers
164
views
Implementing PHP array_column in Rust
I'm in the process of learning Rust, but I could not find an answer to this question.
In PHP, there's the array_column method and it works this way:
given an array of arrays (this would be a a ...
1
vote
1
answer
486
views
array_column doesn't work with first key in nested array
I have a nested array like so
$array = array(
[2] => array(
[5] => array(
[7] => array(
[46] => array()
)
),
[108] => array()
),...
-2
votes
2
answers
216
views
php multidimensional array get prices in specific category [duplicate]
[0] => Array
(
[id] => 004002718
[price] => 5.00
[category] => x
)
[1] => Array
(
[id] => 030285882
[price] => 8.99
[...
3
votes
1
answer
674
views
array_column returning empty array in PHP 5.6 [duplicate]
In a production environment that uses the Yii1 framework and PHP 5.6.40, the array_column function is returning an empty array.
The array is a list of CActiveRecords from another CActiveRecord's ...
0
votes
2
answers
125
views
How do I get index of repeated data from multi dimension array in different variables using array_search() method
how to get index of repeated data from a multi dimension array using array_search() or array_column() method
function Search($value, $array)
{
return(array_search($value, $array,false));
}
$array =...
0
votes
1
answer
55
views
Transform a multidimensional array from PDO to two simple arrays for a chart [duplicate]
I have a MariaDB with articles and each article has a date. I want to display a bar chart with number of articles per date.
I get the data with this code:
$statement = $pdo->prepare(
" SELECT
...
1
vote
3
answers
475
views
Sum a column's values in a 2d array [duplicate]
I have a 2d array like this:
[
['name' => 'Banana', 'quantity' => 124],
['name' => 'Cherry', 'quantity' => 24],
['name' => 'Apple', 'quantity' => 224],
]
How can I sum ...
2
votes
3
answers
311
views
What alternative of code that work in PHP7 in PHP5
I have a PHP code which runs on PHP7 but not in PHP 5, which PHP version in my server, that is my code:
Array (
[0] => stdClass Object (
[userId] => 15
[name] => name0
...
4
votes
4
answers
944
views
Sorting by several array columns with usort [duplicate]
I am aware of the fact that I can usort an array by one column using something like this:
function cmp($a, $b)
{
return $b['column'] - $a['column'];
}
usort($array, "cmp");
This simulates the ...
1
vote
4
answers
3k
views
How to drop pandas row based on values of array column?
I have the following dataframe in pandas:
id name categoryids shops
5 239 Boulanger [5] 152
3 196 Bouygues Telecom [5] 500
4 122 ...
1
vote
1
answer
13k
views
Get multi column from array php, Alternate of array_column [duplicate]
I have used this function to get multi column from array. Alternate of array_column. I have created this function as array_column not work according my requirement.
My Data
$students =
Array
(
[...
1
vote
2
answers
159
views
Print unique values from an array column as a comma-separated string
I want to print all unique Department values from a multidimensional array as a comma-separated string, but not all rows have a Department value.
The boiled down version of my array looks like this:
$...
1
vote
2
answers
336
views
First value duplicate in array while using array_search function [duplicate]
I am trying to remove duplicates from two dimensional array based on client ID. The script removes all duplicates EXCEPT the first value, first client.
I have tried few more ways of comparing result ...
1
vote
2
answers
405
views
How to sort the column sequence of 2D array in AutoIt
Summary:
I'm looking for a proper way to sort a 2D (multidimensional) array by the column sequence in AutoIt. I'm quite familiar with AutoIt and there is the _ArraySort function which provides a ...
0
votes
3
answers
129
views
How can I check and delete duplicate arrays?
how can I check and delete duplicate arrays?
Example:
$a = array(
array(
'id' => 1,
'name' => 'test'
),
// Next array is equal to first, then delete
array(
'id' =&...
-3
votes
5
answers
100
views
Make associative array of unique values from column containing arrays
Array
(
[0] => Array
(
[id] => 21153
[genre] => ["History","Drama", "Thriller"]
)
[1] => Array
(
[id] => 21152
...
-1
votes
4
answers
509
views
How to save a single column from a multidimensional array as a .csv file?
The following code exports the whole array into the .csv file, but I only want to export a specific column.
<?php
$test = array(array("eric", 7),array("nancy" ,8),array("dave", 10));
$fp = fopen('...
0
votes
2
answers
83
views
How to reassign indexes with associative keys using a column value?
I need help to replace some specific subarray indexes with associative keys in my multidimensional array.
My data is coming from an xml file from another system.
For my next process (Import in ...
1
vote
1
answer
311
views
What is the equivalent of array_column in python3
I have a list of dictionary and I want to get only a specific item from each dictionary. My data pattern is:
data = [
{
"_id": "uuid",
"_index": "my_index",
"_score": 1,
...
0
votes
2
answers
48
views
Get count of each unique word across all strings in an array column
I'd like to get a unique word count including all strings in an array column.
Input:
[
[
"Query" => "hehe haha hihi",
"Merry" => "1.11"...
-1
votes
4
answers
146
views
Count number of non-null values in each column of a 2d array
Let's say I have an array:
[
{0:1, 1:5, 3:null},
{0:4, 1:null, 3:null},
{0:null, 1:5, 3:5}
]
I want to count non-null values per associative key so that my expected output is:
[{0:2, 1:2, 3:1}]
5
votes
4
answers
15k
views
In php is there a function like array_column for multidimensional arrays [duplicate]
Is there function that works similar to array_column for multidimensional arrays? Is there a function that translates the first array below to the second:
Array
(
[0] => Array
(
...
2
votes
3
answers
1k
views
PHP sum array values by item.qty
I wonder if there is a faster way to sum i.e. the weight of each item by qty.
$items = [
[
'qty' => 1,
'weight' => 1,
],
[
'qty' => 2,
'...
0
votes
3
answers
783
views
Filter array based on the exploded key value
I have an associated array,
$array2 = array(
array('customer_id' => '01', 'categories' => '',),
array('customer_id' => '02', 'categories' => '',),
array('customer_id' =>...
1
vote
1
answer
74
views
Transform values in an array to another multidimensional array
Currently, this is my code, but it doesn't work:
//$queryBalance is the array received from an sql select
foreach ($queryBalance as $index => $runrows){
$val = $runrows->balance;
$val ...