21 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
2
answers
369
views
PHP - Is it possible to flip only a specific part of a key value array?
Lets say I have the following array:
$array_1 = [
'Green' => 'Tea',
'Apple' => 'Juice',
'Black' => 'Coffee',
];
How do I flip the key => value of ...
2
votes
1
answer
633
views
Flip Every Alternate Row in 2-D array- Python
I am a beginner to programming and was trying how to learn to flip every alternate row in my 2-D array(python)
For Example:
`Input
a=[[1,2,3,4,5],
[10,9,8,7,6],
[11,12,13,14,15],
[...
1
vote
1
answer
2k
views
Using array_flip With or Without a Value
Code used for processing form $_POST submissions is working well on most forms but suddenly broke on a new set of forms. I can't see any difference in the forms themselves as it's based purely on the ...
user avatar
user5175034
2
votes
2
answers
439
views
Flip an associative array and prevent losing new values from new key collisions [duplicate]
I have an array like this:
$files = array(
"Input.txt" => "Randy",
"Code.py" => "Stan",
"Output.txt" => "Randy"
);
I want to group the file by its owner and returned like this:
[...
0
votes
2
answers
738
views
Flip values in array to display them in column instead of row via csv [duplicate]
<?php
// output headers so that the file is downloaded rather than displayed
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename="csv.csv"');
// do not ...
2
votes
2
answers
2k
views
Missing values from the same key after using array_flip function [duplicate]
I'm trying to flip array but it missed value from the key with the same name.
What do I have to use, to add couple values to key which occur multiple times in array?
For example, for
[
"Input....
0
votes
4
answers
1k
views
Create flat, associative array from 2nd level values and 1st level keys of a 2d array
I'm looking for a way to replace nested foreach loops with a functional programming approach. Here is the sample data:
$mode[1] = [1, 2, 5, 6];
$mode[0] = [3, 4, 7, 8];
Currently my code is this:
...
-1
votes
4
answers
1k
views
array_flip with an array in the value
Simple one (but not solved yet): this is my array
[
[
"role" => "admin",
"name" => [
"Felipy",
"Ivan",
],
],
[
"role" => "user",
"name" => [
"Michel",
...
0
votes
1
answer
1k
views
array_flip() expects parameter 1 to be array, null given issue
This is my code.
$param = array('email');
$this->getMapper()->copyfrom('POST',function($val) {
return array_intersect_key($val, array_flip($param));
});
And I get the error in title ...
3
votes
2
answers
1k
views
PHP array_intersect + array_flip with array that has values multiple times [duplicate]
I have two arrays:
$arr1 = array(101 => 250, 102 => 250, 103 => 250, 104 => 500, 105 => 500, 106 => 500,);
and
$arr2 = array(0 => 103, 1 => 104, 2 => 105)
The result I ...
0
votes
2
answers
355
views
array_flip of a key value for letter and numbers
I have an array like this
array(123=>'c', 125=>'b', 139=>'a', 124=>'c', 135=>'c', 159=>'b');
and I want to flip the key/values so that duplicate values become an index for an array.
...
0
votes
5
answers
98
views
Flip an associative array containing duplicate values without losing elements
I wonder if someone can help me. I have an array which I need to group by 'Airport Retailer', 'Seaport Retailer', etc.
Array
(
[World Duty Free Group] => Airport Retailer
[Duty Free ...
4
votes
2
answers
7k
views
PHP - Make an associative array unique, key -> value and value -> key
I have a little problem in php, which i find hard to explain in words. I have an associative array which contains key-value. I would like to make a function (or if there is already one) which would ...
4
votes
3
answers
2k
views
Flip associative array and store new values in subarrays to prevent losing duplicated values
I have a flat associative array which may contain duplicate values.
Array (
[for-juniors] => product_category
[for-men] => product_category
[coats] => product_category
[for-...
-4
votes
3
answers
3k
views
Error "expecting array" with PHP array_flip() function
I recently updated the server on which I work. I have got an error:
"Warning: array_flip() expects parameter 1 to be array, null given in..."
Does someone know how to fix it?
Here is a ...