arrays

php array or not array?

I don't understand... I'm doing something and when I do print_r($var); it tells me that I have an array, so naturally I think I have an array yet when I do if(is_array($xml->searchResult->item)) it returns false I use this array with foreach(); in documentation it says that foreach() won't work with anything else but array, so assu...

Array.Length vs Array.Count

In .NET, pretty much all collections have the .Count property. Sometimes I wonder if it would be better to have it on Array as well, directly though, not through ICollection. It's just something you make an exception in your mind only for arrays. So is it better to be "more correct" or "more uniform" in this case? ...

Solving An Equation in an Array

Hello hello, Im trying to figure out how i can solve an equation that has been stored in an array. I need some guidance on how to conquer such problem. here is my conditions i have an array int X[30]; and in there i have stored my desired equation: 5+6*20/4 as well, i couldnt store the operants (+ / - * ) so i used different identifie...

CakePHP: best way to call an action of another controller with array as parameter?

In a controller, what is the most appropriate way to call the action of another controller and also pass an array as parameter? I know that you can use requestAction to call actions within other controllers. But is it possible to pass arrays as parameters using request action? And no, I do not want to put the action in the App Controll...

Parse JSON array with jQuery .each()

Hi All! I have this jQuery function function getData(jsonLink){ $(".scrollable .items").html("<img class='loadGif' src='/sites/all/themes/zen/journeyon/images/ajax-loader.gif' alt='' />"); $.ajaxSetup({ url: jsonLink, global: false, type: "GET" }); $.ajax({ url: jsonLink, success: function(data) { var...

C# List<double> size vs double[] size

So I just was testing the CLR Profiler from microsoft, and I did a little program that created a List with 1,000,000 doubles in it. I checked the heap, and turns out the List<> size was around 124KB (I don't remember exactly, but it was around that). This really rocked my world, how could it be 124KB if it had 1 million doubles in it? An...

Why am I getting "subscript out of range" when the subscript IS in the range?

I'm working with some legacy spaghetti code that processes some hairy EDI. Most of the code is indecipherable and has no indentation or comments or even good variable names but there's one line that gives me trouble when I remove the On Error Resume Next statement which causes the script to always timeout. If UBound(arylin) >= 1 Then ...

Autocomplete "setup", jquery

I'm trying to get auto-complete working with a simple application that I'm building. Here is my code so far: gMeds = new Array(); $(document).ready(function(){ var autoComp = setUpAutoComplete(); if(autoComp) { $("#med").autocomplete(gMeds); } else { alert('Autocomplete unavailable'); } }); function ...

PHP array, Are array indexes case sensitive?

I don't know if this is a problem yet but wanted to start thinking about it. Question: "Are PHP array indexes case sensitive"? Example: $a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse","A"=>"Dog","B"=>"Cat","C"=>"Horse"); print_r($a); Results: Array ( [a] => Dog [b] => Cat [c] => Horse [A] => Dog [B] => Cat [C] => Horse ) I've run a ...

C: copying struct/array elements

Hello everyone, I have a file in a known format and I want to convert it to a new format, eg.: struct foo { char bar[256]; }; struct old_format { char name[128]; struct foo data[16]; }; struct new_format { int nr; char name[128]; struct foo data[16]; }; s...

How can I use an existing array as a value in a hash in Perl?

I have an existing array I wish to add as a value in a hash. I know you can use arrays as values but can see no way of assigning an existing one. I basically want to go: $hash{fieldName} = @myArray; Only that obviously doesn't work! Help appreciated! ...

Set value array with a query

I want to set this Array with the result of ths Query but I can't. How do I do it ? String[] q = (from p in MDB.aspnet_Memberships where p.aspnet_User.aspnet_UsersInRoles.Single().aspnet_Role.RoleName.ToString() == GroupDDL.SelectedItem.ToString() select new{p.UserId }).ToArray(); Exception ...

How can I reset an array of strings in C language?

Guys, I have a loop that populates "char array_of_strings[100][100];" At some point I want to be able to clean it from all the strings added so far and start adding from position 0. How can I clean/rest it in C? Thanks ...

Java: Serializing String[] Array to store in a MySQL Database?

Yes, I know it's bad practice and I should instead normalize my tables. That put aside, is it possible to serialize a String [] array and store it in the database? I am from the lenient and forgiving world of PHP, where invoking the serialize() function and would convert the array into a string. Is there an equivalent of doing such her...

How to store parse_url as a string in PHP?

Hello again. I have the following code: $array = parse_url($_SERVER['HTTP_REFERER']); $Ur = $array['host']; which displays the domain just fine, but when I use this with sessions, it doesn't work. Also, I tested it with gettype and it returns Null? I thought it was an array? Anywho, how do I go about converting the above $Ur into a...

Java: function for arrays like PHP's join() ?

I want to join a String[] with a glue string. Is there a function for this? ...

How could I print an array slice in awk?

In a file I am reformatting, I would like to put the last column as the first and have the rest of the columns stay the same. I could do this easily in python, but thought I'd learn some awk this evening. Here is an example: (before) polk_describes:1 diatribe_that:1 #label#:negative (after) #label#:negative polk_describes:1 diatri...

Delphi -> Delphi prism, how to use array of records?

Hi there. I'm learning Delphi Prism, and i don't find how to write the following code with it : type TRapportItem = record Label : String; Value : Int16; AnomalieComment : String; end; type TRapportCategorie = record Label : String; CategoriesItems : Array of TRapportItem; end; type TRapportContent = reco...

[PHP] Problem with json_encode()

Hi all, i have an simple array: array 0 => string 'Kum' (length=3) 1 => string 'Kumpel' (length=6) when I encode the array using json_encode(), i get following: ["Kum","Kumpel"] My question is, what is the reason to get ["Kum","Kumpel"] instead of { "0" : "Kum", "1" : "Kumpel" }? ...

PHP: Count Number of Arrays in SESSION

I am storing shopping cart data in a SESSION Array like this: $_SESSION['cart'][$sessID] = array ('quantity' => 1, 'price' => $prodPrice, 'prodName' => $prodName, 'size' => $size, 'handle' => $handle) Each time a user adds an item to the cart, a new sessID is created and a new Session Array. How do I count how many sessID's there are...