179 questions
0 votes
1 answer
77 views
How to stop duplicates in foreach loop with PHP? [duplicate]
I am getting a list categories names based on which tag is selected in WordPress, the code all works and returns a list of categories but I can't get the code to stop the duplicate category names. ...
0 votes
1 answer
76 views
Dividing results table in PHP into sub-tables
I am revising the question I asked before that was not clear at all. I am very much new to PHP programming. I have a table in postgres: | gene_name | description| | gene1 | kuku | | gene1 ...
1 vote
0 answers
40 views
How do I get "explode" and "array_unique" merged
i have two tables, one separates tags by comma, the other converts similar tags to single tags. example: The exploded tags table I got in the database: <?php foreach ($result as $row) { ...
-1 votes
1 answer
38 views
how to get 1 out of each duplicate elements on an array [duplicate]
My function store elements in an array like this: array ( 0 => array ( 'name' => 'Roger', 'id' => '1', ), 1 => array ( 'name' => 'David', 'id' => '2', ),...
0 votes
2 answers
66 views
Remove Duplicate Nested Arrays From Multidimenssional Array By Nested Array Key
I am trying to create an array where I need to filter with a certain key (fileid) so that it returns only unique keys for parent array. Here is what I have.. Array ( [ABCD] => Array ( ...
0 votes
1 answer
51 views
php Keeping only 1 date occurence in multi-dimensional array
I have this array with certain brand_ids, within these brands I have an array of dates in which a sale occured but these are based on the products in sale so they may appear multiple times on the same ...
1 vote
2 answers
1k views
Delete Duplicate from Two arrays and display one of the arrays in javascript
I want delete duplicate array from two arrays, but just show one of array, how I can do it ? I want result [1, 4] const arr1 = [1, 2, 3, 4]; const arr2 = [2, 3, 5, 6] function arrayUniq(arr1, arr2) { ...
-1 votes
2 answers
121 views
PHP Easier way to get unique in array of objects
I have been racking my head trying to think if there is a simpler method to grabbing the unique objects out of an array, but can't find any documentation or confirmation that anything exists that will ...
0 votes
2 answers
136 views
How can I find all results in a PHP array, merge values, and then merge into another array
Using PHP, I have an array like this: Array 1 [ {epid: "123", hash: "xxxxxx"}, {epid: "456", hash: "xxxxxx"}, {epid: "789", hash: "xxxxxx&...
1 vote
0 answers
170 views
Merging Multi-dimensional Array (Custom) PHP - Laravel
Merge a multi-dimensional array to the custom array as required. Need the solution in PHP (using in Laravel-8). Custom array is needed to make rows for creating an excel file using Spreadsheet. This ...
-1 votes
2 answers
904 views
How do I use array_unique() with the output of MySQL query [duplicate]
I have a fairly complex MySQL call that results in simple output something like this; name timestamp comm1 comm2 counter Bill 2021-04-18 19:31:00 data data 1 Bill 2021-04-18 19:32:...
0 votes
1 answer
108 views
PHP array unique does not work like expected [duplicate]
I have a problem with array_unique() in PHP. Here is my code: $filterGroupsArray = ['', 'a', 'a', 'b']; print_r($filterGroupsArray); array_unique($filterGroupsArray); print_r($filterGroupsArray); The ...
-1 votes
1 answer
380 views
what should I use instead of array_unique in php?
I am getting duplicate data in an array and that data is storing in my DB. I am using array_unique to refine the duplicate data but it is not working. Please tell me is there any other way to make ...
0 votes
1 answer
53 views
array_unique() not working while I use preg_match_all php [duplicate]
my code is : $a = <<<'EOD' function makeItBIG($a_lot_of_names) { foreach($a_lot_of_names as $the_simpsons) { $BIG[] = strtoupper($the_simpsons); } return $BIG; } $a_lot_of_names = [...
0 votes
1 answer
133 views
Merge PHP arrays to create named keys and unique values
I have an object which contains 3 arrays, any of which may be empty, it is feasible all three can be empty, so I need to handle that requirement too. Here's an example of the object: { "...