arrays

PHP: get keys of independent arrays

Hello. I have two arrays. Example of the first array: $arrayOne = array ( 'fruit' => array( 'apples' => array(), 'oranges' => array(), 'bananas' => array() ), 'vegetables' => array( 'tomatoes' => array(), 'carrots' => array(), 'celery' => array(), 'beets' => array ...

Javascript: multimensional arrays with key value alternative?

Since I'm more versed in php thank in js I'll try to explain what I need from a php perspective. I need to pass to a javascript function an array: array('fieldname' => 'value', 'fieldname2' => 'value2' ...); Thne the function would do this foreach(array as k => v) { <input name='fieldname' value='value'/> <input name='fieldname2'...

Why does my WCF Service generate Array types when I explicitly set it to List????

I have been consuming a service for some time in development, and have been updating my service reference almost daily with no problems. Collection types have been set to generate as System.Collections.Generic.List in the Advanced options. However, for no apparent reason, now when I update the Service Reference, it's generating Array ty...

Compare matrices problem

I must multiply matrix by itself until the matrix in some degree would not be equal one of the preceding matrices. Then I need to get the values of degrees, in which the matrices are equal. The number of rows and columns are equal. Matrix is stored in a two-dimensional array. Values are 0 or 1. What is the best way to check for equality ...

Difference between MATLAB's numel and length functions

I know that length(x) returns max(size(x)) and numel(x) returns the total number of elements of x, but which is better for a 1 by n array? Does it matter, or are they interchangeable in this case? EDIT: Just for kicks: Looks like they're the same performance-wise until you get to 100k elements. ...

Can I pass subset of an array to function in VB.Net?

I have a simple VB.Net Form that acts as an interface to a control library with a public API. One of the API calls takes an Array of UIntegers ByRef: Public Function Get_Values(source_id As Byte, first_value_address As Byte, number_of_values As Byte, ByRef valuesOut As UInteger()) As Integer After the call, valuesOut will hold a list...

Fast JavaScript array operations

Do any browsers currently support or plan to support fast array math operations, similar to what NumPy provides for Python? Here is an example to demonstrate what I mean: var a = new NumericArray('uint32', [1, 2, 3, 4]); var b = new NumericArray('uint32', [2, 2, 2, 2]); var c = a.add(b); // c == [3, 4, 5, 6] In that example, add is no...

Display a random set of 10 questions and answers with MySQL and PHP

I'm making a survey with PHP and MySQL. I'm having trouble figuring out what method to use to display a random set of 10 questions, and their answers. Each question can have between 2 and 5 answers. Here is how the database is set up: questions: ID | quID | question answers: ID | an_quID | anID | answer quID and an_quID link the tab...

Ruby elegant way to deal card array to player objects

I'm having trouble finding a nice elegant ruby way to do this. I have a deck array with 52 Card objects, and I want to iterate over it and loop through an array of Player objects, dealing one card at a time into their hand array. Something like: deck = Card.deck.shuffle! deck.each do |card| @players.NEXTELEMENT.hand << card end wh...

Iterating JavaScript object properties and arrays with for..in when ordering is important

This has been an age old question and I am aware of the usual reasons for not using for..in or perhaps even objects when any sort of ordering is needed, but I recently came across this article from MDC on the delete operator. Cross-browser issues Although ECMAScript makes iteration order of objects implementation-dependent, it may app...

want to combine multiple array in php

Hi All, i want to do this type in my form i have check box array and the function i want to call as the size of check box array, now all is ok simple one time calling. but i want to call the function as above, and store the function return value in one array as function return array so i want to do like this for user id 1->callfunc...

How do I fit a variable sized char array in a struct?

I don't understand how the reallocation of memory for a struct allows me to insert a larger char array into my struct. Struct definition: typedef struct props { char northTexture[1]; char southTexture[1]; char eastTexture[1]; char westTexture[1]; char floorTexture[1]; char ceilingTexture[1]; } PROPDATA; exampl...

Extract from Php Array using Conditions

I would like to extract the data groups from the PHP arrays depending on the "RouterName". So, in the end, I will get 4 Big Arrays (ArrDeviceA, ArrDeviceB, etc.) I don't want to use foreach and loop every rows and put into the separate array. Moreover, there might be the chance that some arrays might contain more than 3 rows. The nu...

How do I sort a multidimensional array depending on it's items array keys and values?

Hi there. I have an array of permissions: array( array( "controller" => "somewhere", "action" => "", "namespace" => "admin", "method" => "GET" ), array( "controller" => "somewhere", "action" => "index", "namespace" => "admin", "method" => "" ), array( "controller" => "somewhere", "action" => "index", "namespace" => "admin"...

[PHP] Filter an array

I have an array like this: $categories_array = array( [0] => 'category_1', [1] => 'category_2', [2] => 'category_3', [3] => 'category_4' ) I'd like to "filter" the array to get a new one. For example, I'd like to have a new array with only 'category_2' and 'category_3' like this: $new_categories_array = array( [1] => 'category_2', [2...

Query doesn't work

I get the following error message when I try this query: $query .= "($tid, {$_POST['type']['$i']}, 'Y', NOW())"; You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near (18, , 'Y', NOW())' at line 1 Everything in my code works except this line. I know ...

What is a "value" array?

In C, the idea of an array is very straightforward—simply a pointer to the first element in a row of elements in memory, which can be accessed via pointer arithmetic/ the standard array[i] syntax. However, in languages like Google Go, "arrays are values", not pointers. What does that mean? How is it implemented? ...

Will creating new array clear the whole php session data?

Code below: $_SESSION = array(); Will it clear all session data? If I wouldn't want to use session_destory(). ...

How to reverse data using an array of pointers (parse binary file)

Hey I am parsing a binary file using a specification. The file comes in big-endian mode because it has streamed packets accumulated. I have to reverse the length of the packets in order to "reinterpret_cast" them into the right variable type. (I am not able to use net/inet.h function because the packets has different lengths). The read...

Cannot assign data to an object array in WPF with C#

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.IO; nam...