Questions tagged [array-reverse]
29 questions
21
votes
6 answers
Array Reverse is not working for me ...
Consider the following code (React JS code):
poll() {
var self = this;
var url = "//" + location.hostname + "/api/v1/eve/history/historical-data/" + this.state.itemId + '/' + this.state.regionId + '/40';
$.get(url,…

TheWebs
- 12,470
- 30
- 107
- 211
4
votes
3 answers
Passing array value to another array in reverse order
I want to pass int a[] values into int b[]. but I'm facing confusion. Can anyone correct me out. The output of b is 0,0,0,45,4,2,1. it supposed to be like 7,6,5,4,45,2,1.
static void Main()
{
int[] a = new int[] { 1, 2, 45, 4, 5, 6, 7 };
…

Jindal
- 84
- 6
4
votes
2 answers
In PHP how to sort a file in reverse?
i have a text (text.txt) file like this:
shir
beer
geer
deer
i have also a php page with that source:

Ronny
- 285
- 3
- 4
- 10
4
votes
4 answers
Split flat array into chunks of n elements, then reverse the order within each chunk
I want to reverse an array by two elements in each step. If I have an array [11,12,13,14,15,16], I want to reverse first two elements [11,12] and then another two elements [13,14] etc. The final array should be [12,11,14,13,16,15]; My code is below:…

Roman
- 1,118
- 3
- 15
- 37
2
votes
3 answers
C# Array.Reverse reversing the original array passed by value to method
I have a char array in one method, someObject is an arbitrary object passed by reference to the GetChars method:
private void DoSomeStuff(ref Object someObject)
{
char[] chars = GetChars(ref someObject); // {'a','b','c','d'}
char[]…

kataba
- 93
- 6
2
votes
3 answers
PHP Need to recursively reverse an array
I need to recursively reverse a HUGE array that has many levels of sub arrays, and I need to preserve all of the keys (which some are int keys, and some are string keys), can someone please help me? Perhaps an example using array_reverse somehow? …

SoLoGHoST
- 2,673
- 7
- 30
- 51
1
vote
1 answer
Better way to left shift array n times
I am solving a hackerrank question that asks to left shift array n times, and am getting the intended result, but it fails 4 out of 11 cases due to wrong answer (memory issues probably), can you think of a better way to do this?
EDIT: Following the…

Josep Bigorra
- 733
- 2
- 9
- 20
1
vote
2 answers
Javascript variable fix last value after changes
This is my training:
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.getElementById("demo").innerHTML = fruits;
function myFunction() {
var fruits2 = fruits;
fruits2.reverse();
…

Nabi
- 764
- 1
- 10
- 22
1
vote
3 answers
Reversing an Array in Place why does it not work?
function reverseArray(array) {
var reversed_array = [];
for(var i = 0; i < array.length; i++) {
reversed_array.unshift(array[i]);
}
return reversed_array;
}
function reverseArrayInPlace(array) {
console.log(array);…

Yandri
- 41
- 4
1
vote
1 answer
PHP multidimensional array reverse lookup (Amazon Product API)
I am accessing product details through Amazon API and get this in my array of data:
["BrowseNodes"]=>
array(1) {
["BrowseNode"]=>
array(3) {
[0]=>
array(3) {
["BrowseNodeId"]=>
…

Oktarin
- 57
- 2
- 11
1
vote
1 answer
Reverse output from simplexml
Cannot reverse output, tried with array_reverse and usort.
I'm trying to import products from an XML to Magento with magmi datapump, works fine but I need the output in reverse order for Magento to link simple products with configurable…

frednoah
- 13
- 3
0
votes
1 answer
Polars: How to find value in previous values by predicate?
How to find "price" of previous 'top'?
df = DataFrame({
'price': [1, 2, 4, 2, 1, 2, 3, 2],
'spikes': [None, None, 'top', None, 'bottom', None, 'top', None]
})
In result I want to find value of previous top/bottom price.
Expected result…

Joris Medeišis
- 101
- 4
0
votes
0 answers
Reverse the order of an index of numbers in php
my script :
$reverse_sets = array_reverse($sets);
foreach ($extraset as $element) {
foreach ($sets as $index => $set) {
if (in_array($element, $set)) {
$actual_index = count($sets)-$index-1;
echo "Extraset element…

Francesco
- 95
- 6
0
votes
0 answers
ld.exe cannot open output file E:\CLG WRK\cpp\Reverse.exe: Permission denied, [Error] ld returned 1 exit status
I am working on an array problem in which I have to reverse an array.
I wrote this code but it is not working:
#include
using namespace std;
void rev(int reversed_array[], int arr[], int n)
{
for(int i=0;i

Sachin
- 11
0
votes
2 answers
array_reverse() expects parameter 1 to be array, string given in
I am grabbing a .txt file and trying to reverse it, but I get this error when I try to, I don't understand it. Help please?
array_reverse() expects parameter 1 to
be array, string given in ......
Here is the code:
$dirCont =…

alex
- 79
- 1
- 3
- 4