Search Results

Search found 15255 results on 611 pages for 'sparse array'.

Page 40/611 | < Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >

  • Excel Match Bug in a sparse range with duplicate keys

    - by DangerMouse
    Data in TheRange is {1,"",1,"",1,"",1,"",2} =Match(2, TheRange, 1) returns 9 as expected =Match(1.5, TheRange, 1) returns 7 as expected =Match(1, TheRange, 1) returns 5 which is not expected Anyone come across this ? Anyone got a fix? Additionally if I use Worksheet.Function.Match in VBA I get more unexpected results.

    Read the article

  • Getting duplicate key values in array

    - by WmasterJ
    For some reason when trying to populate an array I am not getting the desired result. In the first part I create an array of arrays, the key of each has a name such as "Biology Education". But when I then populate that same array it doesn't for some reason use the same array element but a new one. So part 1 results in an array with 13 array elements (empty). After part 2 has run the array has 26 array elements, with the first 13 empty and the other 13 populated as wanted. The reason why I want to work is that the first 13 array elements are sorted. The last 13 are jumbled. Why is this happening and how can I correct it? // PART 1 // Create array of research areas $research_result = db_fetch_array($research['research_query_result']); $research['areas'] = explode("\n", $research_result['options']); // Put the values as key and every key the new value of an array object $research['areas'] = array_fill_keys($research['areas'], array()); // PART 2 foreach($research['user'] as $uid => &$user_object) { $user_object->profile_research_areas = explode(", ", $user_object->profile_research_areas); foreach($user_object->profile_research_areas as $key => $area) { $research['areas'][$area][] = $uid; } }

    Read the article

  • echo POST array.. or other ideas?

    - by gamerzfuse
    Update: As seen in the Original Questions below, I am looking to echo an array. The problem is that when I send the Moneris gateway to return a POST array to my new file (cart.php) it gets a 500 Internal Server Error. This is the same error I received when it send to the script, which should have worked. Is there any reason that it would always send a 500 Internal Server Error? Cart.php Direct Link Craig ORIGINAL QUESTION: Hello there, I am back for another question. Here is my dilemma: I have a script (ImageFolio Commerce) that hasn't been updated on our server since.. probably 2003. The script had a Payment Gateway (Moneris) manually added to it by the company who offers the script. This costs $1000 to get them to add a gateway. I now have a new client who purchased this business from the previous owner. While switching the account to the new owner's Moneris account, we found out that things have been updated. Long story short.. The Moneris gateway can send 3 types of responses: POST with XML Data POST GET I imagine it is easiest to just use the POST array. I have the file that it sends the response to. As of now the file responds with a Internal Server error, but it does process the order. What I want to do is determine what the POST array is that is being sent, so that I can take it and echo it in a logical manner. Is there a way to capture and echo the entire POST? Or can someone suggest a better method of doing this? Thank you, Craig

    Read the article

  • Removing an array dimension where the elements sum to zero

    - by James
    Hi, I am assigning a 3D array, which contains some information for a number of different loadcases. Each row in the array defines a particular loadcase (of which there are 3) and I would like to remove the loadcase (i.e. the row) if ALL the elements of the row (in 3D) are equal to zero. The code I have at the moment is: Array = zeros(3,5) % Initialise array Numloadcases = 3; Array(:,:,1) = [10 10 10 10 10; 0 0 0 0 0; 0 0 0 0 0;]; % Expand to a 3D array Array(:,:,2) = [10 10 10 10 10; 0 0 0 0 0; 0 0 0 0 0;]; Array(:,:,3) = [10 10 10 10 10; 0 0 0 0 0; 0 0 20 0 0;]; Array(:,:,4) = [10 10 10 10 10; 0 0 0 0 0; 0 0 20 0 0;]; % I.e. the second row should be removed. for i = 1:Numloadcases if sum(Array(i,:,:)) == 0; Array(i,:,:) = [] end end At the moment, the for loop I have to remove the rows causes an indexing error, as the size of the array changes in the loop. Can anyone see a work around for this? Thanks

    Read the article

  • Add items from one array to another

    - by Peterim
    I have two arrays: 1) The first array: array( [0] => array( [code] => code_1 [value] => xxx [1] => array( [code] => code_2 [value] => xxx [2] => array( [code] => code_3 [value] => xxx 2) The second array: array( [0] => array( [settingcode] => code_1 [value] => xxx [1] => array( [settingcode] => code_2 [value] => xxx [2] => array( [settingcode] => code_3 [value] => xxx [3] => array( [settingcode] => code_4 [value] => xxx [4] => array( [settingcode] => code_5 [value] => xxx How can add two missing items (code_4 and code_5) from array2 to array1? Thank you!

    Read the article

  • How do I count how many arrays have the same name within a multidimensional array with php?

    - by zeckdude
    I have a multidimensional array, and I would have multiple arrays within it. Some of those arrays contain multiple arrays within them as well, and I would like to count how many arrays are within the second array(the date). This is an example of the structure of the multidimensional array: $_SESSION['final_shipping'][04/03/2010][book] $_SESSION['final_shipping'][04/12/2010][magazine] $_SESSION['final_shipping'][04/12/2010][cd] This is the foreach statement I am currently using to count how many of the second array(the one with the dates) exists. foreach($_SESSION['final_shipping'] as $date_key => $date_value) { foreach ($date_value as $product_key => $product_value) { echo 'There are ' . count($date_key) . ' of the ' . $date_key . ' selection.<br/>'; } } It is currently outputting this: There are 1 of the 04/03/2010 selection. There are 1 of the 04/12/2010 selection. There are 1 of the 04/12/2010 selection. I would like it to output this: There are 1 of the 04/03/2010 selection. There are 2 of the 04/12/2010 selection.

    Read the article

  • Problems with my JS array undefined x 7

    - by Dave
    I have an array im trying to loop through to create a new type of array specific to my current page. My array looks like this: //$_SESSION['data'] = Array ( [0] => 1 [1] => 0 [2] => Tom [8] => 1 [4] => 1 [5] => Array ( [7] => Array ( [0] => Andrew [1] => 1 [2] => 1 [4] => 0 [5] => avatar.jpg [6] => 1 ) ) [6] => Array ( [0] => 1 [1] => 2 ) ) So in my JS file i have this: var stats = <? echo $_SESSION['data'][5]); ?> ; //this is the array my_data = new Array(); for(var key in stats){ if(key in my_data){} else { //prevent double entry my_data[key] = new Array(); my_data[key][0] = stats[key][6]; my_data[key][1] = stats[key][5]; my_data[key][2] = stats[key][2]; my_data[key][3] = stats[key][0]; } } console.log(my_data); Now in console.log i get this : [undefined × 7, Array[4] 0: "1" 1: "avatar.jpg" 2: "1" 3: "Andrew" length: 4 __proto__: Array[0] ] I'm wondering why it is saying undefined x7?

    Read the article

  • 2 dimensional arrays passed to a function in c++

    - by John Marcus
    I'm working on doing calculations in a two dimensional array but keep getting a nasty error. i call the function by : if(checkArray(array)) and try to pass it in like this: bool checkArray(double array[][10]) //or double *array[][10] to no avail the error is error: cannot convert ‘double ()[(((unsigned int)(((int)n) + -0x00000000000000001)) + 1)]’ to ‘double’ for argument ‘1’ to ‘bool checkArray(double*)’ code snippet //array declaration int n = 10; double array[n][n]; //function call to pass in array while(f != 25) { cout<<endl; cout<<endl; if(checkArray(array)) //this is the line of the error { cout<<"EXIT EXIT EXIT"<<endl; } f++; } //function declaration bool checkArray(double *array)//, double newArray[][10]) { double length = sizeof(array); for(int i = 0; i < length; i++) for(int j = 0; j < length;j++) { double temp = array[i][j]; } }

    Read the article

  • Help regrouping an array

    - by jim
    I'd like to regroup my array. I have the following: Array ( [0] => Array ( [name] => test1 [item_id] => 1 [category] => cat1 ) [1] => Array ( [name] => test2 [item_id] => 2 [category] => cat1 ) [2] => Array ( [name] => test3 [item_id] => 3 [category] => cat1 ) [3] => Array ( [name] => test4 [item_id] => 4 [category] => cat2 ) ) I'd like to regroup it like this: Array ( [cat1] => Array ( [0] => Array ( [name] => test1 [item_id] => 1 ) [1] => Array ( [name] => test2 [item_id] => 2 ) [2] => Array ( [name] => test3 [item_id] => 3 ) ) [cat2] => Array ( [name] => test4 [item_id] => 4 ) ) Can someone tell me how this is best done?

    Read the article

  • Issue pushing object into an array JS

    - by Javacadabra
    I'm having an issue placing an object into my array in javascript. This is the code: $('.confirmBtn').click(function(){ //Get reference to the Value in the Text area var comment = $("#comments").val(); //Create Object var orderComment = { 'comment' : comment }; //Add Object to the Array productArray.push(orderComment); //update cookie $.cookie('order_cookie', JSON.stringify(productArray), { expires: 1, path: '/' }); }); However when I print the array this is the output: Array ( [0] => Array ( [stockCode] => CBL202659/A [quantity] => 8 ) [1] => Array ( [stockCode] => CBL201764 [quantity] => 6 ) [2] => TEST TEST ) I would like it to look like this: Array ( [0] => Array ( [stockCode] => CBL202659/A [quantity] => 8 ) [1] => Array ( [stockCode] => CBL201764 [quantity] => 6 ) [2] Array( [comment] => TEST TEST ) I added products to the array in a similar way and it worked fine: var productArray = []; // Will hold order Items $(".orderBtn").click(function(event){ //Check to ensure quantity > 0 if(quantity == 0){ console.log("Quantity must be greater than 0") }else{//It is so continue //Show the order Box $(".order-alert").show(); event.preventDefault(); //Get reference to the product clicked var stockCode = $(this).closest('li').find('.stock_code').html(); //Get reference to the quantity selected var quantity = $(this).closest('li').find('.order_amount').val(); //Order Item (contains stockCode and Quantity) - Can add whatever data I like here var orderItem = { 'stockCode' : stockCode, 'quantity' : quantity }; //Check if cookie exists if($.cookie('order_cookie') === undefined){ console.log("Creating new cookie"); //Add object to the Array productArray.push(orderItem);

    Read the article

  • Changing key of Multidimensional array in PHP

    - by Thyu
    This is my first array Array ( [0] => Array ( [0] => 1 [1] => Elite [2] => Air-Con Bus [3] => Monday ) [1] => Array ( [0] => 4 [1] => KBZ [2] => Airplane [3] => Wednesday ) [2] => Array ( [0] => 5 [1] => Yoma [2] => Cruise [3] => Tuesday ) ) I want to be inner array[0] to the outer array key. Like the following array: Can I or not? Please suggest me. Array( [1] => Array ( [0] => 1 [1] => Elite [2] => Air-Con Bus [3] => Monday ) [4] => Array ( [0] => 4 [1] => KBZ [2] => Airplane [3] => Wednesday ) [5] => Array ( [0] => 5 [1] => Yoma [2] => Cruise [3] => Tuesday ) )

    Read the article

  • IEnumerable<T> ToArray usage, is it a copy or a pointer?

    - by Daniel
    I am parsing an arbitrary length byte array that is going to be passed around to a few different layers of parsing. Each parser creates a Header and a Packet payload just like any ordinary encapsulation. And my problem lies in how the encapsulation holds its packet byte array payload. Say i have a 100 byte array, and it has 3 levels of encapsulation. 3 packet objects will be created and i want to set the payload of these packets to the corresponding position in the byte array of the packet. For example lets say the payload size is 20 for all levels, then imagine it has a public byte[] Payload on each object. However the problem is that this byte[] Payload is a copy of the original 100 bytes. So i'm going to end up with 160 bytes in memory instead of 100. If it were in c++ i could just easily use a pointer however i'm writing this in c#. So i created the following class: public class PayloadSegment<T> : IEnumerable<T> { public readonly T[] Array; public readonly int Offset; public readonly int Count; public PayloadSegment(T[] array, int offset, int count) { this.Array = array; this.Offset = offset; this.Count = count; } public T this[int index] { get { if (index < 0 || index >= this.Count) throw new IndexOutOfRangeException(); else return Array[Offset + index]; } set { if (index < 0 || index >= this.Count) throw new IndexOutOfRangeException(); else Array[Offset + index] = value; } } public IEnumerator<T> GetEnumerator() { for (int i = Offset; i < Offset + Count; i++) yield return Array[i]; } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { IEnumerator<T> enumerator = this.GetEnumerator(); while (enumerator.MoveNext()) { yield return enumerator.Current; } } } This way i can simply reference a position inside the original byte array but use positional indexing. However if i do something like: PayloadSegment<byte> something = new PayloadSegment<byte>(someArray, 5, 10); byte[] somethingArray = something.ToArray(); Will the somethingArray be a copy of the bytes, or a reference to the original PayloadSegment which in turn is a reference to the original byte array? Sorry it was hard to word this lol _<

    Read the article

  • jquery: why a selector returns me an array, but attribute doesnt?

    - by Shlomi.A.
    Hi. I'm trying to understand JQ better. I'm calling an JQ object $(".FamiliesList li li span[class!='']").prev().find('option:selected') this returns back to me an array of all the options that their span parent's brother has a classname. [option, option] Now- I want to return back an array of the option's values $(".FamiliesList li li span[class!='']").prev().find('option:selected').attr('value') this returns back to me only the first child value, and a full array of the values. Why? I would appreciate to receive help and understand jq better :) Thanks.

    Read the article

  • Print array variables when using or not using double quotes.

    - by Nano HE
    Hi, When I learning to print array variables, I found the white space inserted when double quoter used. Snippet code as below. Could you please tell me why? #!/usr/bin/perl -w use strict; use warnings; my @str_array = ("Perl","array","tutorial"); my @int_array = (5,7,9,10); print @str_array; print "\n"; # added the double quotes print "@str_array"; print "\n"; print @int_array; print "\n"; # added the double quotes print "@int_array"; Output: Perlarraytutorial Perl array tutorial 57910 5 7 9 10

    Read the article

  • How can I check if a Perl array contains a particular value?

    - by Mel
    I am trying to figure out a way of checking for the existence of a value in an array without iterating through the array. I am reading a file for a parameter. I have a long list of parameters I do not want to deal with. I placed these unwanted parameters in an array @badparams. I want to read a new parameter and if it does not exist in @badparams, process it. If it does exist in @badparams, go to the next read.

    Read the article

  • How to remove an item from a structure array in C++?

    - by Antik
    I have the following array structure (linked list): struct str_pair { char ip [50] ; char uri [50] ; str_pair *next ; } ; str_pair *item; I know to create a new item, I need to use item = new str_pair; However, I need to be able to loop through the array and delete a particular item. I have the looping part sorted. But how do I delete an item from an array of structures?

    Read the article

  • How to split this array into three's and place it in <td> using php?

    - by udaya
    Hi I have an php array of ten numbers $arr = array("first" => "1", "second" =>"2", "Third" =>"3", "Fourth" =>"4", "fifth" =>"5",, "sixth" =>"6", "seventh" =>"7", "eighth" =>"8", "ninth" =>"9","tenth"="10"); I have to place these values in a <td> by spliting the array in numbers of three such that my td contains first td contains <td>the first three values of an aray</td> second td contains <td>the next three values of an aray</td> third td contains <td>the next three values of an aray</td> if the remaining values in less than three in number it must be in the another td say now i have tenth value so my last td must contain tenth value

    Read the article

  • How to check null element if it is integer array in Java?

    - by masato-san
    I'm quite new to Java and having an issue checking null element in integer array. I'm using Eclipse for editor and the line that checks null element is showing error: Line that complains: if(a[i] != null) { Error msg from Eclipse: The operator != is undefined for the argument type(s) int, null In PHP, this works without any problem but in Java it seems like I have to change the array type from integer to Object to make the line not complain (like below) Object[] a = new Object[3]; So my question is if I still want to declare as integer array and still want to check null, what is the syntax for it? Code: public void test() { int[] a = new int[3]; for(int i=0; i<a.length; i++) { if(a[i] != null) { //this line complains... System.out.println('null!'); } } }

    Read the article

  • Passing javascript array of objects to WebService

    - by Yousef_Jadallah
    Hi folks. In the topic I will illustrate how to pass array of objects to WebService and how to deal with it in your WebService.   Suppose we have this javascript code :   <script language="javascript" type="text/javascript"> var people = new Array(); function person(playerID, playerName, playerPPD) { this.PlayerID = playerID; this.PlayerName = playerName; this.PlayerPPD = parseFloat(playerPPD); } function saveSignup() { addSomeSampleInfo(); WebService.SaveSignups(people, SucceededCallback); } function SucceededCallback(result, eventArgs) { var RsltElem = document.getElementById("divStatusMessage"); RsltElem.innerHTML = result; } function OnError(error) { alert("Service Error: " + error.get_message()); } function addSomeSampleInfo() { people = new Array(); people[people.length++] = new person(123, "Person 1 Name", 10); people[people.length++] = new person(234, "Person 2 Name", 20); people[people.length++] = new person(345, "Person 3 Name", 10.5); } </script> .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }   .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } poeple :is the array that we want to send to the WebService. person :The function –constructor- that we are using to create object to our array. SucceededCallback : This is the callback function invoked if the Web service succeeded. OnError : this is the Error callback function so any errors that occur when the Web Service is called will trigger this function. saveSignup : This function used to call the WebSercie Method (SaveSignups), the first parameter that we pass to the WebService and the second is the name of the callback function.   Here is the body of the Page : <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> <Services> <asp:ServiceReference Path="WebService.asmx" /> </Services> </asp:ScriptManager> <input type="button" id="btn1" onclick="saveSignup()" value="Click" /> <div id="divStatusMessage"> </div> </form> </body> .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }     Then main thing is the ServiceReference and it’s path "WebService.asmx” , this is the Web Service that we are using in this example.     A web service will be used to receive the javascript array and handle it in our code : using System; using System.Web; using System.Web.Services; using System.Xml; using System.Web.Services.Protocols; using System.Web.Script.Services; using System.Data.SqlClient; using System.Collections.Generic; [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ScriptService] public class WebService : System.Web.Services.WebService { [WebMethod] public string SaveSignups(object [] values) { string strOutput=""; string PlayerID="", PlayerName="", PlayerPPD=""; foreach (object value in values) { Dictionary<string, object> dicValues = new Dictionary<string, object>(); dicValues = (Dictionary<string, object>)value; PlayerID = dicValues["PlayerID"].ToString(); PlayerName = dicValues["PlayerName"].ToString(); PlayerPPD = dicValues["PlayerPPD"].ToString(); strOutput += "PlayerID = " + PlayerID + ", PlayerName=" + PlayerName + ",PlayerPPD= " + PlayerPPD +"<br>"; } return strOutput; } } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } The first thing I implement System.Collections.Generic Namespace, we need it to use the Dictionary Class. you can find in this code that I pass the javascript objects to array of object called values, then we need to deal with every separate Object and explicit it to Dictionary<string, object> . The Dictionary Represents a collection of keys and values Dictionary<TKey, TValue> TKey : The type of the keys in the dictionary TValue : The type of the values in the dictionary. For more information about Dictionary check this link : http://msdn.microsoft.com/en-us/library/xfhwa508(VS.80).aspx   Now we can get the value for every element because we have mapping from a set of keys to a set of values, the keys of this example is :  PlayerID ,PlayerName,PlayerPPD, this created from the original object person.    Ultimately,this Web method return the values as string, but the main idea of this method to show you how to deal with array of object and convert it to  Dictionary<string, object> object , and get the values of this Dictionary.   Hope this helps,

    Read the article

  • Actionscript - Dropping Multiple Objects Using an Array? [closed]

    - by Eratosthenes
    Possible Duplicate: Actionscript - Dropping Multiple Objects Using an Array? I'm trying to get these fireBalls to drop more often, im not sure if im using Math.random correctly also, for some reason I'm getting a null reference because I think the fireBalls array waits for one to leave the stage before dropping another one? this is the relevant code: var sun:Sun=new Sun var fireBalls:Array=new Array() var left:Boolean; function onEnterFrame(event:Event){ if (left) { sun.x = sun.x - 15; }else{ sun.x = sun.x + 15; } if (fireBalls.length>0&&fireBalls[0].y>stage.stageHeight){ // Fireballs exit stage removeChild(fireBalls[0]); fireBalls.shift(); } for (var j:int=0; j<fireBalls.length; j++){ fireBalls[j].y=fireBalls[j].y+15; if (fireBalls[j].y>stage.stageHeight-fireBall.width/2){ } } if (Math.random()<.2){ // Fireballs shooting from Sun var fireBall:FireBall=new FireBall; fireBall.x=sun.x; addChild(fireBall); fireBalls.push(fireBall); } }

    Read the article

  • Data structure for grid with negative indeces

    - by The Secret Imbecile
    Sorry if this is an insultingly obvious concept, but it's something I haven't done before and I've been unable to find any material discussing the best way to approach it. I'm wondering what's the best data structure for holding a 2D grid of unknown size. The grid has integer coordinates (x,y), and will have negative indices in both directions. So, what is the best way to hold this grid? I'm programming in c# currently, so I can't have negative array indices. My initial thought was to have class with 4 separate arrays for (+x,+y),(+x,-y),(-x,+y), and (-x,-y). This seems to be a valid way to implement the grid, but it does seem like I'm over-engineering the solution, and array resizing will be a headache. Another idea was to keep track of the center-point of the array and set that as the topological (0,0), however I would have the issue of having to do a shift to every element of the grid when repeatedly adding to the top-left of the grid, which would be similar to grid resizing though in all likelihood more frequent. Thoughts?

    Read the article

  • Returning PHP Multi-Dimension Array to Javascript/AJAX

    - by GregH
    My understanding is that in order to return a complex PHP variable to Javascript, it should be done via AJAX and json_encode. Could somebody give me an actual example (both PHP and Javascript code) of this? Lets say we have the two-dim array in PHP: $twoDArr = array( array('Greg', 44, 'Owner'), array('Joe', 23, 'Renter'), array('Susan', 39, 'Owner'), array('John', 32, 'Renter) ); How would we return this to an analogous two dimensional array in javascript using json_encode?

    Read the article

  • Get value of element in Multi-Dimensional Array

    - by George
    Here is my foreach loop to get at the values from a multi-dimensional array $_coloredvariables = get_post_meta( $post->ID, '_coloredvariables', true ); foreach ($_coloredvariables as $key => $value) { var_dump($value); } Which outputs this: array 'label' => string 'Color' (length=5) 'size' => string 'small' (length=5) 'displaytype' => string 'square' (length=6) 'values' => array 'dark-night-angel' => array 'type' => string 'Image' (length=5) 'color' => string '#2c4065' (length=7) 'image' => string '' (length=0) 'forest-green' => array 'type' => string 'Color' (length=5) 'color' => string '#285d5f' (length=7) 'image' => string '' (length=0) 'voilet' => array 'type' => string 'Color' (length=5) 'color' => string '#6539c9' (length=7) 'image' => string '' (length=0) 'canary-yellow' => array 'type' => string 'Color' (length=5) 'color' => string 'grey' (length=4) 'image' => string '' (length=0) And then to only get the values array I can do this: foreach ($_coloredvariables as $key => $value) { var_dump($value['values']); } which outputs this: array 'dark-night-angel' => array 'type' => string 'Image' (length=5) 'color' => string '#2c4065' (length=7) 'image' => string '' (length=0) 'forest-green' => array 'type' => string 'Color' (length=5) 'color' => string '#285d5f' (length=7) 'image' => string '' (length=0) 'voilet' => array 'type' => string 'Color' (length=5) 'color' => string '#6539c9' (length=7) 'image' => string '' (length=0) 'canary-yellow' => array 'type' => string 'Color' (length=5) 'color' => string 'grey' (length=4) 'image' => string '' (length=0) What I can't figure out is how to get these elements in the array structure "dark-night-angel", "forest-green", "voilet", "canary-yellow" Without using specific names: var_dump($value['values']['dark-night-angel']) Something that is more dynamic, of course this doesn't work: var_dump($value['values'][0][0]); thanks

    Read the article

< Previous Page | 36 37 38 39 40 41 42 43 44 45 46 47  | Next Page >