Tagged Questions
33
votes
9answers
13k views
Checking if array is multidimensional or not?
What is the most efficient way to check if an array is a flat array
of primitive values or if it is a multidimensional array?
Is there any way to do this without actually looping through an
array and ...
11
votes
4answers
80k views
PHP foreach loop through multidimensional array
I have an array:
$arr_nav = array( array( "id" => "apple",
"url" => "apple.html",
"name" => "My Apple"
),
array( "id" => "orange",
"url" => ...
4
votes
1answer
1k views
Lisp: multidimensional array elementwise operations
What is the "correct" construct in Common Lisp to apply elementwise operations to multidimensional arrays?
The following examples should help illustrate what I'm trying to do:
A) Suppose I want to ...
4
votes
3answers
721 views
Find the max value in an array
My requirement is to find the greatest/max value in an array, which may contain other arrays within it. For example we could have a look at an array below.
$array =
array(
13,
...
3
votes
6answers
141 views
Another php array looping question
Been battling with this one for what seems, like forever.
I have an array:
$url_array
It contains this info:
Array (
[ppp] => Array (
[0] => stdClass Object (
[id] ...
3
votes
4answers
122 views
Create a new array from another array
I have two arrays. The first one contains of places and some information about them. It's a multidimensional array in three steps:
Step 1: Category (e.g. header, date etc...).
Step 2: The actual ...
3
votes
2answers
42 views
Comparison of methods appending arrays in a foreach loop
I've set up an array of associative arrays (with dummy data for testing) like this:
// To hold dropdown filter options
$results['filters'] = array('Client' => array( array('a' => '1') ),
...
3
votes
1answer
68 views
Looping through a multi-dimensional array
I have a JSON file that looks similar to this:
{
"Pages":{
"/":{
"Name": "Home",
"Page": "index.php"
},
"/_admin":{
"Name": "Admin",
...
3
votes
1answer
156 views
Extract values from a multidimensional array
I have a very big array with car makes and models. I've already extracted the makes into a separate array, but I am struggling to extract the models while also maintaining their association to the ...
2
votes
3answers
389 views
Python: I am unable to comprehend the concept of a For Loop, apparently
I've got a list of 400 numbers, and i want to but them in a 20x20 grid using Python.
I've made a "2d array" (not really because Python doesn't support them, I've had to use a list of lists.)
When i ...
2
votes
2answers
3k views
Looping a multidimensional array in php
I have a multidimensional array like this:
array(2) {
[1]=>
array(3) {
["eventID"]=>
string(1) "1"
["eventTitle"]=>
string(7) "EVENT 1"
["artists"]=>
array(3) ...
2
votes
5answers
70 views
Iterating through many arrays in C
I have a header file that has many arrays. Each array pair (i.e. x0, y0) are the same length, but different pairs have different lengths.
numPaths[] = 4;
pathLengths[] = {12, 11, 13, 10};
int x0[] ...
2
votes
2answers
156 views
How do I make an iterator over a 2-dimensional table in Lua?
I've got a lua table made of tables, so it's two-dimensional: root -> child -> grandchild.
None of the levels of this hierarchy is guaranteed to be "array-like". The first level has integers with ...
2
votes
2answers
954 views
Python: Efficiently iterating over a multidimensional list
I'm using for-loops to iterate over two-dimensional list:
def itr(lpic, lH, lW, x, y):
'''lpic=2D-Array; lH=Row_count; lW=Column_count;'''
stack = []
range_x = range(x-1, x+2)
range_y ...
2
votes
3answers
105 views
Multidimensional arrays
I have a php multidimensional array which looks like this:
$fields = array( array('input', 'title', 'slug', 'keywords'),
array('textarea', 'content'),
array('radio', 'active', 'active2', ...