Tagged Questions
0
votes
3answers
36 views
Recursively edit multidimensional array
I have a multidimensional array containing some text strings that need modifying. My initial thought was to iterate over it recursively and make the edits, but I've realised that calling the function ...
0
votes
2answers
45 views
Create multidimensional array recursively
The original array looks like this:
$array = array(
array(
'key' => 'key1',
'val' => 'val1'
),
array(
'key' => 'key2:subkey1',
'val' => 'val2'
...
2
votes
1answer
35 views
Get array child from recursive function
I have variable with child from database. So for example:
$roots = $this->getCategoryTable()->getCategoryRoot($project_id);//themes
if($roots->count()> 0){
...
0
votes
1answer
69 views
Multidimensional Directory List with Recursive iterator
I am trying to get multi-dimensional array for directories formatted as below :
[
{
"text": "another_folder",
"href": "gui\/default\/uploads\/another_folder",
"depth": ...
0
votes
1answer
21 views
Recursive Multidimensional Highlighting Function
I just got finished coding this recursive function (my first one).
It takes in $data, either an array or string, and an array of $terms to match against. It then matches, gets the entire word (not ...
0
votes
2answers
56 views
Directory Folders/Files list to Array php
I have small function which gives me Directory Folders/Files list as multidimensional Array.
How can I have directory list with following structure. (Schema no : 3)
function dirToArray($dir) {
...
0
votes
1answer
33 views
Walkthrough Entire Multidimensional Array PHP
I have a dummy array, that I want to order.
How can I have following result
with foreach?
with while next()
with RecursiveIterator
with IteratorIterator
which one is the fastest?
Here is array
...
0
votes
3answers
71 views
Multidimensional Array Listing Printing Php
I have following array with php code
I could not find where I am mistaken
I'm trying to filter some of these array results and delete them. When I try to list them I could not succeded
array (
0 ...
1
vote
1answer
26 views
build tree with a multidimensional array
how to make tree with the following multidimensional array?
the child items have a non-zero parentID
Array
(
[0] => Array
(
[id] => 6
[title] => zzz
...
0
votes
1answer
44 views
make tree with a multidimensional array
how to make tree with the following multidimensional array?
the child items have a non-zero parentID
Array
(
[0] => Array
(
[id] => 6
[title] => zzz
...
1
vote
2answers
32 views
Recursively chain specific values together without passing an array by reference
Imagine the following multi-dimensional array:
$a = array(
'key' => 'hello',
'children' => array(
array(
'key' => 'sub-1'
),
array(
'key' => 'sub-2',
...
0
votes
0answers
15 views
How can I use recursion to combine a multi-dimensional array of user subscriptions into renewals and expirations?
I'm trying to build a renewals/expirations system. To consolidate what a user has in his/her account, I've got to recursively combine their existing subscriptions and get rid of their expired ones if ...
0
votes
1answer
46 views
How do I generate a flat array of indexes from a multi dimensional array?
I have the following array from PHP:
Array
(
[0] => Array
(
[ContractExhibitsData] => Array
(
[id] => 2
...
1
vote
1answer
74 views
Turn one dimensional array with string path into multi dimensional json object
I am trying to parse some data and just cant seem to figure it out myself. I have the array data of something like this, where the string should be turned into a path to the array index. See below:
...
0
votes
0answers
25 views
Flattening multidimensional array after certain depth
I've got an multidimensional array that I want to flatten after its depth is greater than 2.
Further to this, it also needs to concatenate the name key in each of its children as it gets flattened.
...
0
votes
1answer
34 views
Recursive get path from multidimensional php array
I have array:
$adm_menu_old = array (
array(
'id' => 1,
'name' => 'Test1',
),
array(
'id' => 3,
'name' => 'Test3',
'childrens' => ...
0
votes
2answers
48 views
How to access n dimensional array using recursion
I set x is array contains several variables with are inputs of a evaluation function. Each
variable has limit defined in xBoundary[index][min,max]. Each possible variable value has step size ...
0
votes
0answers
52 views
Recursive array merge, group by key when multidimensionnal
I'm struggling with this one since i'm new with PHP. I'm crying for help to organise/tidy my output array.
I have an array like this (direct output from SQL, multiple joins).
array(8) {
[0] = ...
1
vote
1answer
57 views
Sorting comments into a multidimensional array using recursion PHP
I fetch my commments using MYSQL, with the format
comment_id, parent_id, group_id, message
Where the parent_id can be empty if the comment is a 1st level comment.
I store my nested comments, i.e ...
0
votes
1answer
56 views
PHP recursion array using MYSQL data
I have a table with data, this data is represented as rows each row is a task, a task might have a subtask and that subtask might have a subtask as well. This represents, to make it easier vinyl ...
0
votes
3answers
68 views
C++ recursive function that has a byref 2D Matrix of object pointers
I have a recursive funtion that has a parameter that is a reference to a 2D matrix of object pointers. My simple question is in what format do I pass that within the function so that it would work?
I ...
0
votes
1answer
65 views
Failing to recursively filter multidimensional array of objects
I have a variable which may be an object or an array. If it is an array, it will be of objects. Each object may have a parameter which is another object or an array of objects. All arrays may be n ...
0
votes
1answer
26 views
Wrapping each child key within an UL
I'm wanting to wrap each child array within an <ul>, but I'm not entirely sure how it may be done?
function RecursiveWrite($array) {
foreach ($array as $v) {
echo '<li>';
...
0
votes
1answer
38 views
Alternative way of accessig an array within array in PHP
I'm trying to access an array within another array (basically, a two dimensional array). However, the usual way of doing this ($myarray[0][0]) doesn't work for me.
The reason is because I want to ...
1
vote
1answer
182 views
Java - Deep clone array using recursion ; unknown type and unknown depth
I have tried everything I can think of and have searched for it everywhere online, but I can't get it to work. Below I have two Java methods, the first one I successfully got to work, and the other I ...
7
votes
3answers
1k views
How to get the sum of two n-dimensional arrays in Java?
Adding two n-dimensional arrays in Java
addVectors
Two 1-dimensional arrays / vectors in Java can be added like this:
public static int[] addVectors( int[] a, int[] b )
{
int[] c = new ...
2
votes
2answers
164 views
Renaming object keys recursively
I have a recursive function to rename the key names of an object but I'm unable to figure out how to rename 2 of the keys (problem keys are objects)
I think the problem is where I'm checking for ...
0
votes
1answer
28 views
Transform tree category array to one line
I have got an array (category tree)
[category_name_en] => en
[category_name_ru] => ru
[id_category] => 86314
[children] => Array
(
[category_name_en] => en 2
...
0
votes
2answers
1k views
PHP Recursive menu function
I have a very similar situation to this post
PHP: nested menu with a recursive function, expand only some nodes (not all the tree)
and I need some help...
Here is the (partial) contents of my ...
0
votes
1answer
81 views
extract multidimentional array into a nested list
I'm trying to extract a multidimensional array I got from a Nestable Plugin into a Ordered List by the Plugin's HTML structure.
The Recursion I've build is not enought because the OL tag I'm creating ...
0
votes
1answer
62 views
Create flat array from recursive function instead of flattening after
I have a recursive function that does a lot of functioning and some database calls and what not to create some cool stuff. I want to save the results of each call to the function into an array.
So ...
1
vote
0answers
248 views
PHP: How to update/extend an multidimensional Array recursive and on-the-fly?
I've a multidimensional array and would like to update/add some values, recursive. I'd like to avoid building a new array, if possible. But I've two main problems:
How to update the values ...
0
votes
0answers
31 views
Category count including children from
I am currently working on a script, that can make a multidimensional array have counts of a category's number of product uniquely assign to that category (cat_count) AND a count of the total of ...
0
votes
3answers
92 views
An elegant way of walking a multidimensional dict with a list of keys?
I want to walk a multidimensional dict using a list of keys. At the last key, I will return the value.
I'll be given the list and it will map to the keys of the dictionary, but I won't know how deep ...
0
votes
4answers
648 views
Php recursive array counting
I'm trying to write a function which counts array elements recursively.
But result is false.
What could it be problem?
$schema = array(
'div' => array(
'class' => 'lines',
...
1
vote
2answers
46 views
recursive function - help returning value when calling function
I have a multi-dim array to search:
> Array (
> [91] => Array
> (
> [FoSW] => 117
> [DfLR] => 107
> [FoA] => 0
> ...
10
votes
6answers
635 views
PHP Array: join each sub-array together (Probability)
I want simply to find-out better way to do this:
$array = array(
array('a', 'b', 'c'),
array('e', 'f', 'g'),
array('h', 'i', 'j', 'k', 'l')
);
The goals is to print something like this:
...
1
vote
0answers
211 views
PHP: find and replace values in multi dimensional array
I have this multi dimensional array in the form of tree.
$menu = array('records'=>array(
array('id'=>1,
'parent_id'=>NULL,
...
2
votes
2answers
806 views
PHP check if some keys or values are in a multidimensional array
I have an array structure where I want to check if a key/value is present somewhere in the array. But I want to make the test in such a way that I make a an almost mirrored validation array.
Lets say ...
1
vote
1answer
145 views
Recursive word group array searching
I've been working on search function that will let me group specific words then recursively search for them in an array and I've coded myself into a hole I think. This is my first foray into ...
1
vote
3answers
178 views
Haskell multidimensional list : Beginner problems
I want to delete every string in a list which starts with "h".
["hawrw", "basw", "HasD" , "hgkas"] => ["basw", "HasD"]
My code is:
kat (x:xs) = if head x == "h" then kat(xs) else x ++ kat(xs)
...
-5
votes
1answer
205 views
Multi dimensional array combinations [closed]
Please help me with solving this problem in multidimensional Array
I have
Array
(
[1] => Array
(
[0] => 10
)
[2] => Array
(
[0] => Array
...
0
votes
1answer
74 views
Create hierarchial array from single dimensional array
I want to create a hierarchial array from the single dimensional array obtained from database. Language is PHP.
In the below mentioned example key id -3 indicates that it is the root node.
Input ...
3
votes
3answers
266 views
Array with variable number of elements, counting up
I want an multidimensional array, where each element is an array of X elements - lets say 3.
I basically want to count from 0 to y (lets say 12) in the 3rd element, then after 0,0,12 I want the next ...
1
vote
2answers
88 views
converting plain array to multidimensional one using recursion
everyone!
I'm stuck trying write a recursive function. =(
This is my function, which, as I expected, will turn my plain array into multidimensional one.
function BuildTree($src, $index=0) {
...
4
votes
2answers
933 views
Algorithm Complexity (Big-O) of sudoku solver
I'm look for the "how do you find it" because I have no idea how to approach finding the algorithm complexity of my program.
I wrote a sudoku solver using java, without efficiency in mind (I wanted ...
0
votes
2answers
96 views
How to do recursion?
How transform one array to other with recursion? This example works only to second level.
$array2 = array();
foreach ($array as $levelKey => $level) {
foreach ($level as $itemKey => $item) {
...
0
votes
1answer
86 views
How get array from multidimensional array by order
I have this kind of array:
array(2) {
[1] => array(3) {
[3] => array(3) {
["data"] => array(3) {
["id"] => string(1) "3"
["depth"] => string(1) "1"
...
1
vote
2answers
309 views
Using ArrayList to get two dimensional array data
My input is a text document grid of 0's and 1's, which i then put into a two dimensional integer array.
The object for me is to "map" the 1's in the grid. I have to determine how many groups of 1's ...
0
votes
1answer
57 views
Identifying connecting elements in an array
So what I am trying to do with this problem is given a grid of numbers I want to have have the location of an even number in the grid and by having that one location it will find all other even ...