arrays

Why this PHP snippet not working?

$i = 'i'; $arr = array('hi' => 'test'); echo "$arr[h$i]";exit(); What's the right version to do it without {}? Say,I know can do it with "{$arr['h' . $i]}" EDIT 1.inside "" 2.with operation like ".",i.e,['h' . $i] 3.without {} ...

Ruby on Rails Has Many Through Array Problem

Hi all, I'm having problems adding to a Has Many Through association using user_ids. My communication model looks like this: class communication has_many :recipients has_many :users, :through => :recipients end In my create action for the communication controller I am trying to manually add user_ids to the communication object lik...

Why is this snippet compilable in C?

Possible Duplicate: In C arrays why is this true? a[5] == 5[a] 3["zdvnngfgnfg"]; ...

Find all second level keys in multi-dimensional array in php

I want to generate a list of the second level of keys used. Each record does not contain all of the same keys. But I need to know what all of the keys are. array_keys() doesn't work, it only returns a list of numbers. Essentially the output Im looking for is: action, id, validate, Base, Ebase, Ftype, Qty, Type, Label, Unit I have a la...

How to print an array to a .txt file in Matlab?

I am just beginning to learn Matlab, so this question might be very basic: I have a variable a=[2.3 3.422 -6.121 9 4.55] I want the values to be output to a .txt file like this: 2.3 3.422 -6.121 9 4.55 How can I do this? fid = fopen('c:\\coeffs.txt','w'); //this opens the file //now how to print 'a' to the file?? ...

put Custom Class Array into a dataset or XML (C#)

I am making a small card game which required a high score list that is saved to an external file, and loaded from it at the begining of each each game. I wrote an xml file in this format bob 10 3:42 21-09-09 I have figured out how to create a dataset, use dataset.readxml, to load the xml into it, create a row and then write each row...

Javascript array operation

var arr = ['test','hello']; is there a javascript native call to get index of some value('hello') in an array? ...

Access array returned by a function in php

I'm using a templating engine that inserts code in my site where I want it. I wrote a function to test for something which is quite easy: myfunction() { return '($this->data["a"]["b"] ? true : false)'; } The problem is, $this->data is private, and I can't access it everywhere, so I have to use getData(); which causes my problem. $th...

c# How to retrieve Json data into an array

Hi! I have found different libraries that can parse Json data, but i did not find any documentation on how to get the data into an C# array or list. I got this Json data: {"001":{"Name":"John", "Phone":["Mob - 98837374","Mob - 98363627"]}, "002":{"Name":"Tom", "Phone":["Mob - 49858857"]}} Anybody got a clue? :) Edit: Useful detail...

Does the array size matter in javascript in this case?

I'm creating an array in javascript using item id's from the database whenever a corresponding button is clicked on the page. Each array entry will store a custom object. The id's from the database for a specific can start from any number like 80123 to 80223, for that specific page of data. so the first entry in the array will be like ...

Are C# arrays thread safe?

In particular Create a function to take an array and an index as parameters. Create a n element array. Create a n count loop. Inside the loop on a new thread assign a new instance of the object to the array using the indexer passed in. I know how to manage the threads etc. I am interested in know if this is thread safe way of doing...

pop array in php

I need to have this output Array ( [id:>] => 0 [isonline] => 0 [userclass_id] => 3 ) and I am getting this output with this code: $pr = array('id:>'=>$id,'isonline'=>'0','userclass_id'=>'3'); print_r($params); This is good. But i want to pop new elements to array one by one. While i am using this code: $params = array(); ...

PHP array with default value for nonexisting indices

I love the Hash implementation of Ruby where you can initialize the Hash object with a default value. At the moment I'm struggling with implementing a similar object in PHP. This is my first (non-working) shot at this. class DefaultArray extends ArrayObject { protected $_defaultValue; public function setDefault($defaultValue) { ...

Return index of highest value in an array

From an array that looks something like the following, how can I get the index of the highest value in the array. For the array below, the desired result would be '11'. Array ( [11] => 14 [10] => 9 [12] => 7 [13] => 7 [14] => 4 [15] => 6 ) ...

what is array decaying?

what is decaying of array? is there any relation to the array pointers? ...

asp:textbox array

Hey! how does one do something like this with asp.net <asp:textbox> and c #? (Thus creating an array of text boxes) HTML: <input name="Search[]" value="google" /> <input name="Search[]" value="yahoo" /> <input name="Search[]" value="alltheweb" /> PHP: $array = $_GET['Search']; // or $_POST['Search']; /* $array is now an array like:...

Merging php arrays if "clientid" is identical?

Hi all, I have a query which gives back an array, I'd like to be able to merge the array values which have the same "clientid" Here's my query: SELECT * FROM #__db_clients_trip WHERE clientid IN (1999, 2984, 1681) AND companyid IN (1,2) Here's my array: stdClass Object ( [id] => 61 [trip_code] => EUR0600 [clientid] => 19...

How can I use this PHP array?

I used to use the function below for an array or IP's but now I have changes the IP array from this: $bannedIPs = array('127.0.0.0','72.189.218.85'); // Banned IPs array ipban($bannedIPs); function ipban($bannedIPs) { if (in_array($_SERVER['REMOTE_ADDR'], $bannedIPs)) { include ("site_banip.php"); session_destroy(); ...

JQuery retriving the next greatest element

Hi, in JQuery i m having an array like (1,2,6,8) I have already selected the first element that is 1 which i have saved in a JQuery variable submitterid = 1 On clicking a link I am trying to get the next greatest element in the Array than what I have selected in the submitterid.. How can I achieve this? Edit: How to find the l...

Getting index from value in JavaScript

Is there a function/method to retrieve the index of an item in an array from its value in JavaScript? In other words I'm looking for the JavaScript equivalent for the Python .index() lists method: >>> ['stackoverflow','serverfault','meta','superuser'].index('meta') 2 Does the wheel already exist or have I to reinvent it? ...