Search Results

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

Page 36/611 | < Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >

  • Array Intersect giving wrong output

    - by Pankaj Khurana
    Hi, I need to find common elements between two arrays. My code is: $sql="SELECT DISTINCT fk_paytbl_discounts_discountid as discountid from paytbl_discounts_students WHERE fk_vtiger_cf_601='".$categoryid."'"; $discountstudentinfo=$objdb->customQuery($sql,false); $sql1="SELECT DISTINCT fk_paytbl_discounts_discountid as discountid from paytbl_discounts_variants WHERE fk_vtiger_products_productid='".$variantid."'"; $discountvariantinfo=$objdb->customQuery($sql1,false); $commondiscount=array_intersect($discountvariantinfo,$discountstudentinfo); First array Array ( [0] => Array ( [discountid] => 2 ) [1] => Array ( [discountid] => 8 ) [2] => Array ( [discountid] => 5 ) [3] => Array ( [discountid] => 4 ) ) Second array Array ( [0] => Array ( [discountid] => 1 ) [1] => Array ( [discountid] => 5 ) ) Common array Array ( [0] => Array ( [discountid] => 1 ) [1] => Array ( [discountid] => 5 ) ) Common array should have only discountid 5 but its showing 1 also. Please help me on this Thanks

    Read the article

  • Duplicate array but maintain pointer links

    - by St. John Johnson
    Suppose I have an array of nodes (objects). I need to create a duplicate of this array that I can modify without affecting the source array. But changing the nodes will affect the source nodes. Basically maintaining pointers to the objects instead of duplicating their values. // node(x, y) $array[0] = new node(15, 10); $array[1] = new node(30, -10); $array[2] = new node(-2, 49); // Some sort of copy system $array2 = $array; // Just to show modification to the array doesn't affect the source array array_pop($array2); if (count($array) == count($array2)) echo "Fail"; // Changing the node value should affect the source array $array2[0]->x = 30; if ($array2[0]->x == $array[0]->x) echo "Goal"; What would be the best way to do this?

    Read the article

  • How do I create and populate a non-uniformly structured array in PHP?

    - by stormist
    I am trying to decide on a data structure for an array that has a date for the key and the amount of bandwidth consumed as values. examples Key Consumed Policy October 50 Basic November 75 Basic December 100 Basic Some months, but not all, will have more than one policy. In that case, I need break them down by policy once the total is shown. So for the above example, assume December had 3 policies. The table i construct from my array would then need to show: Key Consumed Policy October 50 Basic November 75 Basic December 100 .. December 25 Basic December 25 Extended December 50 Premium Could all this data be represented in an array ? $myArray['december'] would be a different data structure than the others because it would need a last entry, probably another array, that had the policy names as keys and the amount of data consumed as values. Does PHP allow for arrays that are not structured uniformly? i.e. key october and November have only 2 entries under their key while December has 2 entries plus a 3rd which is an additional array. My best guess is something like: Array ( [October] => "50", "Basic" [November] => "75", "Basic" [December] => "100", "..", Array( [Basic] => 25 [Extended] =>25 [Premium] => 50 ) ) My question is if this is possible and how to declare it and populate it with values with PHP. Thanks in advance for any clarifications or assistance!

    Read the article

  • php: parsing and converting array structure

    - by mwb
    I need to convert one array structure into another array structure. I hope someone will find it worthy their time to show how this could be done in a simple manner. It's a little above my array manipulation skills. The structure we start out with looks like this: $cssoptions = array( array( 'group' => 'Measurements' , 'selector' => '#content' , 'rule' => 'width' , 'value' => '200px' ) // end data set , array( 'group' => 'Measurements' , 'selector' => '#content' , 'rule' => 'margin-right' , 'value' => '20px' ) // end data set , array( 'group' => 'Colors' , 'selector' => '#content' , 'rule' => 'color' , 'value' => '#444' ) // end data set , array( 'group' => 'Measurements' , 'selector' => '.sidebar' , 'rule' => 'margin-top' , 'value' => '10px' ) // end data set ); // END $cssoptions It's a collection of discreet datasets, each consisting of an array that holds two key = value pairs describing a 'css-rule' and a 'css-rule-value'. Further, each dataset holds a key = value pair describing the 'css-selector-group' that the 'css-rule' should blong to, and a key = value pair describing a 'rule-group' that should be used for structuring the rendering of the final css into a neat css code block arranged by the kind of properties they describe (colors, measurement, typography etc..) Now, I need to parse that, and turn it into a new structure, where the: 'rule' => 'rule-name' , 'value' => 'value-string' for each dataset is converted into: 'rule-name' => 'value-string' ..and then placed into a new array structure where all 'rule-name' = 'value-string' pairs should be aggregated under the respective 'selector-values' Like this: '#content' => array( 'width' => '200px' , 'margin-right' => '20px' ) // end selecor block ..and finally all those blocks should be grouped under their respective 'style-groups', creating a final resulting array structure like this: $css => array( 'Measurements' => array( '#content' => array( 'width' => '200px' , 'margin-right' => '20px' ) // end selecor block , '.sidebar' => array( 'margin-top' => '10px' ) // end selector block ) // end rule group , 'Colors' => array( '#content' => array( 'color' => '#444' ) // end selector block ) // end rule group ); // end css

    Read the article

  • C++ dynamic array sizing problem

    - by Peter
    The basic pseudo code looks like this: void myFunction() { int size = 10; int * MyArray; MyArray = new int[size]; cout << size << endl; cout << sizeof(MyArray) << endl; } The first cout returns 10, as expected, while the second cout returns 4. Anyone have an explanation?

    Read the article

  • Multi-Dimensional Array and ArrayIndexOutOfBoundsException

    - by notset
    Hello, I have a strange problem which I can't fix: A field: private boolean[][][] gaps; Constructor (1st line): gaps = new boolean[NOBARRICADES][WIDTH][HEIGHT]; Constructor (2nd line): for (int i = 0; i < NOBARRICADES; i++) { JAVA throws an error for the 2nd line, saying: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException Does it have anything to do with JAVA syntax (the mistake is in these lines of code) or I should look for the problem somewhere else?

    Read the article

  • string reverse without new array

    - by Codeguru
    hi can anybody tell me the error in this? #include<stdio.h> int main() { char a[]="abcdefgh"; int i=0; int n=strlen(a); char *first; char *second; char *c; *first=a[0]; *second=a[7]; for(i=0;i<=n/2;i++) { *c=*first; *first=*second; *second=*c; first++; second--; } for(i=0;i<=7;i++) { printf("%c",a[i]); } }

    Read the article

  • Unexpected output on initializing array by using both `element-by-element` & `designated` technique

    - by haccks
    C99 provides a feature to initialize arrays by using both element-by-element & designated method together as: int a[] = {2,1,[3] = 5,[5] = 9,6,[8] = 4}; On running the code: #include <stdio.h> int main() { int a[] = {2,1,[3] = 5,[0] = 9,4,[6] = 25}; for(int i = 0; i < sizeof(a)/sizeof(a[0]); i++) printf("%d ",a[i]); return 0; } (Note that Element 0 is initialized to 2 and then again initialised by designator [0] to 9) I was expecting that element 0(which is 2) will be replaced by 9(as designator [0] = 9) and hence o/p will become 9 1 0 5 4 0 25 Unfortunately I was wrong as o/p came; 9 4 0 5 0 0 25 Any explanation for unexpected o/p?

    Read the article

  • Array manipulation in gsettings' set command

    - by Daniel
    Is there an easy way to do array manipulation in gsettings? I am comparing gsettings to OS X's defaults command that offers the defaults domain --array key overwrite-value and defaults domain --array-add key added-value interface for manipulating arrays. As far as I can tell there is only gsettings set domain key "['overwrite-value']" available to gsettings. Not really pretty for when you want to add or remove one entry from an array. I have seen a suggestion that allow me to add to an array, but I would rather use a interface if there is one.

    Read the article

  • Reconstructing Position in the Original Array from the Position in a Stripped Down Array

    - by aronchick
    I have a text file that contains a number of the following: <ID> <Time 1> --> <Time 2> <Quote (potentially multiple line> <New Line Separator> <ID> <Time 1> --> <Time 2> <Quote (potentially multiple line> <New Line Separator> <ID> <Time 1> --> <Time 2> <Quote (potentially multiple line> <New Line Separator> I have a very simple regex for stripping these out into a constant block so it's just: <Quote> <Quote> <Quote> What I'd like to do is present the quotes as a block to the user, and have them select it (using jQuery.fieldSelection) and then use the selected content to back out to the original array, so I can get timing and IDs. Because this has to go out to HTML, and the user has to be able to select the text on the screen, I can't do anything like hidden divs or hidden input fields. The only data I will have is the character range selected on screen. To be specific, this is what it looks like: 1 0:00 --> 0:05 He was bored. So bored. His great intellect, seemingly inexhaustible, was hungry for new challenges but he was the last of the great innovators 2 0:05 --> 0:10 - society's problems had all been solved. 3 0:11 --> 0:20 All seemingly unconnected disciplines had long since been found to be related in horrifically elusive and contrived ways and he had mastered them all. And this is what I'd like to present to the user for selection: He was bored. So bored. His great intellect, seemingly inexhaustible, was hungry for new challenges but he was the last of the great innovators - society's problems had all been solved. All seemingly unconnected disciplines had long since been found to be related in horrifically elusive and contrived ways and he had mastered them all. Has anyone com across something like this before? Any ideas how to take the selected text, or selection position, and go backwards to the original meta-data?

    Read the article

  • efficient video format/codec for sparse & binary blob tracking

    - by user391339
    I am working on a blob tracking project and have many high-definition videos that I would like to reduce in size for storage and downstream tracking/shape-analysis. I want to use a lossless method that takes advantage of the black and white nature of the video as well as the fact that not much is moving between individual frames. The videos are quite sparse, with 5 to 10 b&w blobs per frame occupying <30% of the space in total, with each blob moving <5-10% of the field of view between frames and not changing shape too much between 2-3 frames. I will work in Python, Matlab, or LabView for this project, and could use a batch utility if available. It may be worthwhile to export the files as compressed image stacks if a proper video format can't be found. What are the pros and cons of this? A video codec uses correlations between neighboring frames, so it should be more efficient, but not if the wrong one is chosen or if it is improperly configured.

    Read the article

  • Percentage difference between different values in the same keys of two different arrays.

    - by Paul
    Hey. I'm looking for a solution to this problem. I got 2 arrays, like this: array(2) { [20100526]=> array(1) { ["ga:pageviews"]=> string(5) "19088" } [20100527]=> array(1) { ["ga:pageviews"]=> string(5) "15566" } } array(2) { [20100526]=> array(1) { ["ga:pageviews"]=> string(5) "12043" } [20100527]=> array(1) { ["ga:pageviews"]=> string(5) "11953" } } Now I'd like to create a new array, with the % difference between the values per key. Would be something like this: array(2) { [20100526]=> array(1) { ["ga:pageviews"]=> string(5) "88,23" } [20100527]=> array(1) { ["ga:pageviews"]=> string(5) "74,54" } } Can anyone help me how to create that array?

    Read the article

  • Is there a way to find how how "deep" a PHP array is?

    - by Thomas Owens
    A PHP array can have arrays for its elements. And those arrays can have arrays and so on and so forth. Is there a way to find out the maximum nesting that exists in a PHP array? An example would be a function that returns 1 if the initial array does not have arrays as elements, 2 if at least one element is an array, and so on.

    Read the article

  • C# print 2D-array in order. Please help!

    - by user339067
    Hello, I got a 2-dimentional array containing boolean values written in C#. The cols and rows of the array are to be determined by the user upon creation of the array. I then want to print out the array and it´s containing values onto the console in order. For example like this, how is this done in C#? ROWS - COLS - VALUE 1 - A - True 1 - B - True 1 - C - True 1 - D - True 2 - A - True 2 - B - False 2 - C - False 2 - D - True

    Read the article

  • I need to create a very large array of bits/boolean values. How would I do this in C/C++?

    - by Eddy
    Is it even possible to create an array of bits with more than 100000000 elements? If it is, how would I go about doing this? I know that for a char array I can do this: char* array; array = (char*)malloc(100000000 * sizeof(char)); If I was to declare the array by char array[100000000] then I would get a segmentation fault, since the maximum number of elements has been exceeded, which is why I use malloc. Is there something similar I can do for an array of bits?

    Read the article

  • How can we calculate where the aaray ends?

    - by udaya
    Hi I have an array result like this, example 1: Array ( [0] =>15 [1] => 16 [2] => 17 [3] => 18 ) example 2: Array ( [0] =15 [1] = 16 [2] = 17 [3] = 18 [4] = 18 ) The first array ends at array[3] The second array ends at array[4] How to calculate where the array ends Is there any function to calculate this

    Read the article

  • How do I randomly fill an array in Java?

    - by Kat
    I'm writing a program that creates a 2D array from a integer n. I then have to fill the array with values from 1 to the n*n array size and check to see if it is a magic square. The way I am doing it now fills the array in order from 1 to n*n array size. How can I make that random? My code: System.out.print("Enter an whole number: "); int n = scan.nextInt(); int [][] magic = new int [n][n]; for (int row = 0; row < magic.length; row++) { for(int col = 0; col < magic[row].length; col++) magic[row][col] = ((row * n) + 1) + col; }

    Read the article

  • Letting a new PHP page know a new POST value is an Array?

    - by Wintermute
    I have a page that creates an associative array, then passes it as a hidden value to a new PHP page. I have a foreach loop waiting to iterate through it but it coughs up an "invalid argument" error, as if the page doesn't know the value it's working with is an array (Despite "print" showing simply "Array"). This is essentially what I have: //Hidden input to be passed to the next page print "<input type=\"hidden\" name=\"price_list\" value=\"$item_list\"> //Code on the second page for the foreach loop extract($_POST); foreach($price_list as $name=>$price) { ... } But I am simply given "Warning: Invalid argument supplied for foreach() in /home/cut/mg299/public_html/PHP/invoice.php on line 17". The array works fine, as I can iterate on the previous page, and other values are parsed fine to this second page. Do I need to 'reinitialise' this array value?

    Read the article

  • How do you retrieve the array adapter currently set for a spinner? Android OS, Droid

    - by Sean
    Looking to create a menu toggle that switches between two possible arrays for a spinner. For example, if the spinner is set to show array A, then when I press this menu button, I want the spinner to be set to array B. If I press it again, I want it to be set back to array A. I can handle the if/then statements and all, but how do I call the spinner's array adapter? I know how to call its value using getSelectedItemPosition(); but is there a similar method for retrieving WHICH array it is currently set to?

    Read the article

  • How can I extract values out of this array?

    - by Jagira
    Array ( [status] => success [abc] => Array ( [0] => Array ( [name] => John Doe [age] => 23) [1] => Array ( [name] => John Doe_1 [age] => 23) [2] => Array ( [name] => John Doe_2 [age] => 23) ) ) When I try foreach($stories as $story){ } It returns an error.

    Read the article

  • Fastest way to zero out a 2d array in C?

    - by Eddy
    I want to repeatedly zero a large 2d array in C. This is what I do at the moment: for(j = 0; j < n; j++) { for(i = 0; i < n; i++) { array[i][j] = 0; } } I've tried using memset: memset(array, 0, sizeof(array)) But this only works for 1D arrays. When I printf the contents of the 2D array, the first row is zeroes, but then I got a load of random large numbers and it crashes.

    Read the article

  • new >> how would i read a file that has 3 columns and each column contains 100 numbers into an array

    - by user320950
    int exam1[100];// array that can hold 100 numbers for 1st column int exam2[100];// array that can hold 100 numbers for 2nd column int exam3[100];// array that can hold 100 numbers for 3rd column void main() { ifstream infile; int num; infile.open("example.txt");// file containing numbers in 3 columns if(infile.fail()) // checks to see if file opended { cout << "error" << endl; } while(!infile.eof()) // reads file to end of line { for(i=0;i<100;i++); // array numbers less than 100 { while(infile >> [exam]); // while reading get 1st array or element ???// how will i go read the next number infile >> num; } } infile.close(); }

    Read the article

< Previous Page | 32 33 34 35 36 37 38 39 40 41 42 43  | Next Page >