Search Results

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

Page 43/611 | < Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >

  • Finding and marking the largest of three values in a two dimensional array

    - by DavidYell
    I am working on a display screen for our office, and I can't seem to think of a good way to find the largest numerical value in a set of data in a two dimensional array. I've looked at using max() and also asort() but they don't seem to cope with a two dimensional array. I'm returning my data through our mysql class, so the rows are returned in a two dimensional array. Array( [0] => Array( [am] => 12, [sales] => 981), [1] => Array( [am] => 43, [sales] => 1012), [2] => Array( [am] => 17, [sales] => 876) ) I need to output a class when foreaching the data in my table for the AM with the highest sales value. Short of comparing them all in if statements. I have tried to get max() on the array, but it returns an array, as it's look within the dimension. When pointing it at a specific dimension it returns the key not the value. I figured that I could asort() the array and pop the top value off, store it in a variable and then compare against that in my foreach() loop, but that seems to have trouble sorting across two dimensions. Lastly, I figured that I could foreach() the values, comparing them against the previous one each time, untill I found the largest. This approach however means storing every value, luckily only three, but then comparing against them all again. Surely there must be a simpler way to achieve this, short of converting it into a single dimension array, then doing an asort() on that?

    Read the article

  • Why doesen't the number 2 work in this for-loop?

    - by Emil
    Hello. I have a function that runs trough each element in an array. It's hard to explain, so I'll just paste in the code here: NSLog(@"%@", arraySub); for (NSString *string in arrayFav){ int favoriteLoop = [string intValue] + favCount; NSLog(@"%d", favoriteLoop); id arrayFavObject = [array objectAtIndex:favoriteLoop]; [arrayFavObject retain]; [array removeObjectAtIndex:favoriteLoop]; [array insertObject:arrayFavObject atIndex:0]; [arrayFavObject release]; id arraySubFavObject = [arraySub objectAtIndex:favoriteLoop]; [arraySubFavObject retain]; [arraySub removeObjectAtIndex:favoriteLoop]; [arraySub insertObject:arraySubFavObject atIndex:0]; [arraySubFavObject release]; id arrayLengthFavObject = [arrayLength objectAtIndex:favoriteLoop]; [arrayLengthFavObject retain]; [arrayLength removeObjectAtIndex:favoriteLoop]; [arrayLength insertObject:arrayLengthFavObject atIndex:0]; [arrayLengthFavObject release]; } NSLog(@"%@", arraySub); The array arrayFav contains these strings: "3", "8", "2", "10", "40". Array array contains 92 strings with a name. Array arraySub contains numbers 0 to 91, representing a filename with a title from the array array. Array arrayLength contains 92 strings representing the size of each file from array arraySub. Now, the first NSLog shows, as expected, the numbers 0 to 91. The NSLog-s in the loop shows the numbers 3, 8, 2, 10, 40, also as expected. But here's the odd part: the last NSLog shows these numbers: 40, 10, 0, 8, 3, 1, 2, 4, 5, 6, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91 that is 40, 10, 0, 8, 3, and so on. It was not supposed to be a zero in there, it was supposed to be a 2.. Do you have any idea at why this is happening or a way to fix it? Thank you.

    Read the article

  • CakePHP - Paginating an Array

    - by Ashok
    Cake handles pagination of a model with a simple $this-paginate(), but what should I use if I want to paginate a array of values? The Scenario is like this: $this->set('sitepages', $this->paginate()); This code in my index() returns an array like Array ( [0] => Array ( [Sitepage] => Array ( [id] => 13 [name] => Home [urlslug] => home [parent_id] => 1 [page_title] => Welcome to KIAMS, Pune [order] => 1 ) ) [1] => Array ( [Sitepage] => Array ( [id] => 26 [name] => About Us [urlslug] => aboutus [parent_id] => 1 [page_title] => [order] => 2 ) ) [2] => Array ( [Sitepage] => Array ( [id] => 27 [name] => Overview of KIAMS [urlslug] => aboutus/overview [parent_id] => 26 [page_title] => [order] => 2 ) ) I retrieved the same data using $this-Sitepage-find('all') and then performed some manipulations as required and form a array which is very similar to the above one, but the ordering gets changed. I want to paginate this new array and pass it to the view. I tried $this->set('sitepages',$this->paginate($newarray)) But the data is not getting paginated. Can some one please help with paginating the $newarray in CakePHP?

    Read the article

  • Trouble recording unique regex output to array in perl

    - by Structure
    The goal of the following code sample is to read the contents of $target and assign all unique regex search results to an array. I have confirmed my regex statement works so I am simplifying that so as not to focus on it. When I execute the script I get a list of all the regex results, however, the results are not unique which leads me to believe that my manipulation of the array or my if (grep{$_ eq $1} @array) { check is causing a problem(s). #!/usr/bin/env perl $target = "string to search"; $inc = 0; $once = 1; while ($target =~ m/(regex)/g) { #While a regex result is returned if ($once) { #If $once is not equal to zero @array[$inc] = $1; #Set the first regex result equal to @array[0] $once = 0; #Set $once equal to zero so this is not executed more than once } else { if (grep{$_ eq $1 } @array ) { #From the second regex result, check to see if the result is already in the array #If so, do nothing } else { @array[$inc] = $1; #If it is not, then assign the regex search result to the next unused position in the array in any position. $inc++; #Increment to next unused array position. } } } print @array; exit 0;

    Read the article

  • php Getting the 'new' values in an array

    - by Mark
    Trying to learn about php's arrays today. I have a set of arrays like this: $a = array ( 0 => array ( 'value' => 'America', ), 1 => array ( 'value' => 'England', ), 2 => array ( 'value' => 'Australia', ), ) $b = array ( 0 => array ( 'value' => 'America', ), 1 => array ( 'value' => 'England', ), 2 => array ( 'value' => 'Canada', ), ) I need to get the 'new' subarrays that array b brings to the table. ie, I need to return array ( 'value' => 'Canada', ) I thought I could first merge $a+$b and then compare the result to $a. $merge = array_merge($a,$b); $result = array_diff($merge,$a); But somehow that does not work. It returns array() How come? And thanks!

    Read the article

  • Populating a PHP array within a foreach loop

    - by patrick
    I am wanting to add each user into an array and check for duplicates before I do. $spotcount = 10; for ($topuser_count = 0; $topuser_count < $spotcount; $topuser_count++) //total spots { $spottop10 = $ids[$topuser_count]; $top_10 = $gowalla->getSpotInfo($spottop10); $usercount = 0; $c = 0; $array = array(); foreach($top_10['top_10'] as $top10) //loop each spot { //$getuser = substr($top10['url'],7); //strip the url $getuser = ltrim($top10['url'], " users/" ); if ($usercount < 3) //loop only certain number of top users { if (($getuser != $userurl) && (array_search($getuser, $array) !== true)) { //echo " no duplicates! <br /><br />"; echo ' <a href= "http://gowalla.com'.$top10['url'].'"><img width="90" height="90" src= " '.$top10['image_url'].' " title="'.$top10['first_name'].'" alt="Error" /></a> '; $array[$c++] = $getuser; } else { //echo "duplicate <br /><br />"; } } $usercount++; } print_r($array); } The previous code prints: Array ( [0] => 62151 [1] => 204501 [2] => 209368 ) Array ( [0] => 62151 [1] => 33116 [2] => 122485 ) Array ( [0] => 120728 [1] => 205247 [2] => 33116 ) Array ( [0] => 150883 [1] => 248551 [2] => 248558 ) Array ( [0] => 157580 [1] => 77490 [2] => 52046 ) Which is wrong. It does check for duplicates, but only the contents of each foreach loop instead of the entire array. How is this if I am storing everything into $array?

    Read the article

  • Creating array from two arrays

    - by binoculars
    I'm having troubles trying to create a certain array. Basicly, I have an array like this: [0] => Array ( [id] => 12341241 [type] => "Blue" ) [1] => Array ( [id] => 52454235 [type] => "Blue" ) [2] => Array ( [id] => 848437437 [type] => "Blue" ) [3] => Array ( [id] => 387372723 [type] => "Blue" ) [4] => Array ( [id] => 73732623 [type] => "Blue" ) ... Next, I have an array like this: [0] => Array ( [id] => 34141 [type] => "Red" ) [1] => Array ( [id] => 253532 [type] => "Red" ) [2] => Array ( [id] => 94274 [type] => "Red" ) I want to construct an array, which is a combination of the two above, using this rule: after 3 Blues, there must be a Red: Blue1 Blue2 Blue3 Red1 Blue4 Blue5 Blue6 Red2 Blue7 Blue8 Blue9 Red3 Note that the their can be more Red's than Blue's, but also more Blue's than Red's. If the Red's run out, it should begin with the first one again. Example: let's say there are only two Red's: Blue1 Blue2 Blue3 Red1 Blue4 Blue5 Blue6 Red2 Blue7 Blue8 Blue9 Red1 ... ... If the Blue's run out, the Red's should append until they run out too. Example: let's say there are 5 Blue's, and 5 Red's: Blue1 Blue2 Blue3 Red1 Blue4 Blue5 Red2 Red3 Red4 Red5 Note: the arrays come from mysql-fetches. Maybe it's better to fetch them while building the new array? Anyway, the while-loops got to me, I can't figure it out... Any help is much appreciated!

    Read the article

  • PHP - My array returns NULL values when placed in a function, but works fine outside of the function

    - by orbit82
    Okay, let me see if I can explain this. I am making a newspaper WordPress theme. The theme pulls posts from categories. The front page shows multiple categories, organized as "newsboxes". Each post should show up only ONCE on the front page, even if said post is in two or more categories. To prevent posts from duplicating on the front page, I've created an array that keeps track of the individual post IDs. When a post FIRST shows up on the front page, its ID gets added to the array. Before looping through the posts for each category, the code first checks the array to see which posts have ALREADY been displayed. OK, so now remember how I said earlier that the front page shows multiple categories organized as "newsboxes"? Well, these newsboxes are called onto the front page using PHP includes. I have 6 newsboxes appearing on the front page, and the code to call them is EXACTLY the same. I didn't want to repeat the same code 6 times, so I put all of the inclusion code into a function. The function works, but the only problem is that it screws up the duplicate posts code I mentioned earlier. The posts all repeat. Running a var_dump on the $do_not_duplicate variable returns an array with null indices. Everything works PERFECTLY if I don't put the code inside a function, but once I do put them in a function it's like the arrays aren't even connecting with the posts. Here is the code with the arrays. The key variables in question here include $do_not_duplicate[] = $post-ID, $do_not_duplicate and 'post__not_in' = $do_not_duplicate <?php query_posts('cat='.$settings['cpress_top_story_category'].'&posts_per_page='.$settings['cpress_number_of_top_stories'].'');?> <?php if (have_posts()) : ?> <!--TOP STORY--> <div id="topStory"> <?php while ( have_posts() ) : the_post(); $do_not_duplicate[] = $post->ID; ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail('top-story-thumbnail'); ?></a> <h2 class="extraLargeHeadline"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <div class="topStory_author"><?php cpress_show_post_author_byline(); ?></div> <div <?php post_class('topStory_entry') ?> id="post-<?php the_ID(); ?>"> <?php if($settings['cpress_excerpt_or_content_top_story_newsbox'] == "content") { the_content(); ?><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><span class="read_more"><?php echo $settings['cpress_more_text']; ?></span></a> <?php } else { the_excerpt(); ?><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><span class="read_more"><?php echo $settings['cpress_more_text']; ?></span></a> <?php }?> </div><!--/topStoryentry--> <div class="topStory_meta"><?php cpress_show_post_meta(); ?></div> <?php endwhile; wp_reset_query(); ?> <?php if(!$settings['cpress_hide_top_story_more_stories']) { ?> <!--More Top Stories--><div id="moreTopStories"> <?php $category_link = get_category_link(''.$settings['cpress_top_story_category'].''); ?> <?php if (have_posts()) : ?> <?php query_posts( array( 'cat' => ''.$settings['cpress_top_story_category'].'', 'posts_per_page' => ''.$settings['cpress_number_of_more_top_stories'].'', 'post__not_in' => $do_not_duplicate ) ); ?> <h4 class="moreStories"> <?php if($settings['cpress_make_top_story_more_stories_link']) { ?> <a href="<?php echo $category_link; ?>" title="<?php echo strip_tags($settings['cpress_top_story_more_stories_text']);?>"><?php echo strip_tags($settings['cpress_top_story_more_stories_text']);?></a><?php } else { echo strip_tags($settings['cpress_top_story_more_stories_text']); } ?> </h4> <ul> <?php while( have_posts() ) : the_post(); $do_not_duplicate[] = $post->ID; ?> <li><h2 class="mediumHeadline"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2> <?php if(!$settings['cpress_hide_more_top_stories_excerpt']) { ?> <div <?php post_class('moreTopStory_postExcerpt') ?> id="post-<?php the_ID(); ?>"><?php if($settings['cpress_excerpt_or_content_top_story_newsbox'] == "content") { the_content(); ?><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><span class="read_more"><?php echo $settings['cpress_more_text']; ?></span></a> <?php } else { the_excerpt(); ?> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><span class="read_more"><?php echo $settings['cpress_more_text']; ?></span></a> <?php }?> </div><?php } ?> <div class="moreTopStory_postMeta"><?php cpress_show_post_meta(); ?></div> </li> <?php endwhile; wp_reset_query(); ?> </ul> <?php endif;?> </div><!--/moreTopStories--> <?php } ?> <?php echo(var_dump($do_not_duplicate)); ?> </div><!--/TOP STORY--> <?php endif; ?> And here is the code that includes the newsboxes onto the front page. This is the code I'm trying to put into a function to avoid duplicating it 6 times on one page. function cpress_show_templatebitsf($tbit_num, $tbit_option) { global $tbit_path; global $shortname; $settings = get_option($shortname.'_options'); //display the templatebits (usually these will be sidebars) for ($i=1; $i<=$tbit_num; $i++) { $tbit = strip_tags($settings[$tbit_option .$i]); if($tbit !="") { include_once(TEMPLATEPATH . $tbit_path. $tbit.'.php'); } //if }//for loop unset($tbit_option); } I hope this makes sense. It's kind of a complex thing to explain but I've tried many things to fix it and have had no luck. I'm stumped. I'm hoping it's just some little thing I'm overlooking because it seems like it shouldn't be such a problem.

    Read the article

  • Device or resource busy errors when setting up a RAID array

    - by JGazlyVFX
    I'm trying to create a Raid array and these are the errors I keep getting. I have repartitioned the drives several times. root@BitchStewie:/dev# sudo mdadm --verbose --create /dev/md1 --chunk=64 --level=0 --raid-devices=12 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1 /dev/sdg1 /dev/sdh1 /dev/sdi1 /dev/sdj1 /dev/sdk1 /dev/sdl1 /dev/sdm1 mdadm: super1.x cannot open /dev/sdb1: Device or resource busy mdadm: ddf: Cannot use /dev/sdb1: Device or resource busy mdadm: Cannot use /dev/sdb1: It is busy mdadm: device /dev/sdb1 not suitable for any style of array

    Read the article

  • problem in array of shooter sprites which contain different colour bubbles

    - by prakash s
    everyone i am developing bubble shooter game in cocos2d I have placed shooter array which contain different color bubbles like this 00000000 it is 8 bubbles array if i tap the screen, first bubbles should move for shooting the target .png .And if i again tap the screen again 2nd position bubble should move for shooting the target.png bubbles,how it will possible for me because i have already created the array of target which contain different color bubbles, here i write the code : - (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { // Choose one of the touches to work with UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:[touch view]]; location = [[CCDirector sharedDirector] convertToGL:location]; // Set up initial location of projectile CGSize winSize = [[CCDirector sharedDirector] winSize]; NSMutableArray * movableSprites = [[NSMutableArray alloc] init]; NSArray *images = [NSArray arrayWithObjects:@"1.png", @"2.png", @"3.png", @"4.png",@"5.png",@"6.png",@"7.png", @"8.png", nil]; for(int i = 0; i < images.count; ++i) { int index = (arc4random() % 8)+1; NSString *image = [NSString stringWithFormat:@"%d.png", index]; CCSprite*projectile = [CCSprite spriteWithFile:image]; //CCSprite *projectile = [CCSprite spriteWithFile:@"3.png" rect:CGRectMake(0, 0,256,256)]; [self addChild:projectile]; [movableSprites addObject:projectile]; float offsetFraction = ((float)(i+1))/(images.count+1); //projectile.position = ccp(20, winSize.height/2); //projectile.position = ccp(18,0 ); //projectile.position = ccp(350*offsetFraction, 20.0f); projectile.position = ccp(10/offsetFraction, 20.0f); // projectile.position = ccp(projectile.position.x,projectile.position.y); // Determine offset of location to projectile int offX = location.x - projectile.position.x; int offY = location.y - projectile.position.y; // Bail out if we are shooting down or backwards if (offX <= 0) return; // Ok to add now - we've double checked position //[self addChild:projectile]; // Determine where we wish to shoot the projectile to int realX = winSize.width + (projectile.contentSize.width/2); float ratio = (float) offY / (float) offX; int realY = (realX * ratio) + projectile.position.y; CGPoint realDest = ccp(realX, realY); // Determine the length of how far we're shooting int offRealX = realX - projectile.position.x; int offRealY = realY - projectile.position.y; float length = sqrtf((offRealX*offRealX)+(offRealY*offRealY)); float velocity = 480/1; // 480pixels/1sec float realMoveDuration = length/velocity; // Move projectile to actual endpoint [projectile runAction:[CCSequence actions: [CCMoveTo actionWithDuration:realMoveDuration position:realDest], [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)], nil]]; // Add to projectiles array projectile.tag = 1; [_projectiles addObject:projectile]; } }

    Read the article

  • Array Problem, need to sort via Keys

    - by sologhost
    Ok, not really sure how to do this. I have values that are being outputted from a SQL query like so: $row[0] = array('lid' => 1, 'llayout' => 1, 'lposition' => 1, 'mid' => 1, 'mlayout' => 1, 'mposition' => 0); $row[1] = array('lid' => 2, 'llayout' => 1, 'lposition' => 0, 'mid' => 2, 'mlayout' => 1, 'mposition' => 0); $row[2] = array('lid' => 2, 'llayout' => 1, 'lposition' => 0, 'mid' => 3, 'mlayout' => 1, 'mposition' => 1); $row[3] = array('lid' => 3, 'llayout' => 1, 'lposition' => 1, 'mid' => 4, 'mlayout' => 1, 'mposition' => 1); $row[4] = array('lid' => 4, 'llayout' => 1, 'lposition' => 2, 'mid' => 5, 'mlayout' => 1, 'mposition' => 0); etc. etc. Ok, so the best thing I can think of for this is to give lid and mid array keys and have it equal the mposition into an array within the while loop of query like so... $old[$row['lid']][$row['mid']] = $mposition; Now if I do this, I need to compare this array's keys with another array that I'll need to build based on a $_POST array[]. $new = array(); foreach($_POST as $id => $data) { // $id = column, but we still need to get each rows position... $id = str_replace('col_', '', $id); // now get the inner array... foreach($data as $pos => $idpos) $new[$id][$idpos] = $pos; } Ok, so now I have 2 arrays of info, 1 from the database, and another from the $_POST positions, I hope I got the array keys correct. Now I need to figure out which one's changed, comparing from the old to the new. And also, need to update the database with all of the new positions where new lid = the old lid, and the new mid = the old mid from each array. I'm sure I'll have to use array_key or array_key_intersect somehow, but not sure exactly how...??? Also, I don't think an UPDATE would be useful in a foreach loop, perhaps there's a way to do a CASE statement in the UPDATE query? Also, Am I going about this the right way? OR should I do it another way instead of using a muli-dimensional array for this.

    Read the article

  • Can't Remove Logical Drive/Array from HP P400

    - by Myles
    This is my first post here. Thank you in advance for any assistance with this matter. I'm trying to remove a logical drive (logical drive 2) and an array (array "B") from my Smart Array P400. The host is a DL580 G5 running 64-bit Red Hat Enterprise Linux Server release 5.7 (Tikanga). I am unable to remove the array using either hpacucli or cpqacuxe. I believe it is because of "OS Status: LOCKED". The file system that lives on this array has been unmounted. I do not want to reboot the host. Is there some way to "release" this logical drive so I can remove the array? Note that I do not need to preserve the data on logical drive 2. I intend to physically remove the drives from the machine and replace them with larger drives. I'm using the cciss kernel module that ships with Red Hat 5.7. Here is some information pertaining to the host and the P400 configuration: [root@gort ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 5.7 (Tikanga) [root@gort ~]# uname -a Linux gort 2.6.18-274.el5 #1 SMP Fri Jul 8 17:36:59 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux [root@gort ~]# rpm -qa | egrep '^(hp|cpq)' cpqacuxe-9.30-15.0 hp-health-9.25-1551.7.rhel5 hpsmh-7.1.2-3 hpdiags-9.3.0-466 hponcfg-3.1.0-0 hp-snmp-agents-9.25-2384.8.rhel5 hpacucli-9.30-15.0 [root@gort ~]# hpacucli HP Array Configuration Utility CLI 9.30.15.0 Detecting Controllers...Done. Type "help" for a list of supported commands. Type "exit" to close the console. => ctrl all show config detail Smart Array P400 in Slot 0 (Embedded) Bus Interface: PCI Slot: 0 Cache Serial Number: PA82C0J9SVW34U RAID 6 (ADG) Status: Enabled Controller Status: OK Hardware Revision: D Firmware Version: 7.22 Rebuild Priority: Medium Expand Priority: Medium Surface Scan Delay: 15 secs Surface Scan Mode: Idle Wait for Cache Room: Disabled Surface Analysis Inconsistency Notification: Disabled Post Prompt Timeout: 0 secs Cache Board Present: True Cache Status: OK Cache Ratio: 25% Read / 75% Write Drive Write Cache: Disabled Total Cache Size: 256 MB Total Cache Memory Available: 208 MB No-Battery Write Cache: Disabled Cache Backup Power Source: Batteries Battery/Capacitor Count: 1 Battery/Capacitor Status: OK SATA NCQ Supported: True Logical Drive: 1 Size: 136.7 GB Fault Tolerance: RAID 1 Heads: 255 Sectors Per Track: 32 Cylinders: 35132 Strip Size: 128 KB Full Stripe Size: 128 KB Status: OK Caching: Enabled Unique Identifier: 600508B100184A395356573334550002 Disk Name: /dev/cciss/c0d0 Mount Points: /boot 101 MB, /tmp 7.8 GB, /usr 3.9 GB, /usr/local 2.0 GB, /var 3.9 GB, / 2.0 GB, /local 113.2 GB OS Status: LOCKED Logical Drive Label: A0027AA78DEE Mirror Group 0: physicaldrive 1I:1:2 (port 1I:box 1:bay 2, SAS, 146 GB, OK) Mirror Group 1: physicaldrive 1I:1:1 (port 1I:box 1:bay 1, SAS, 146 GB, OK) Drive Type: Data Array: A Interface Type: SAS Unused Space: 0 MB Status: OK Array Type: Data physicaldrive 1I:1:1 Port: 1I Box: 1 Bay: 1 Status: OK Drive Type: Data Drive Interface Type: SAS Size: 146 GB Rotational Speed: 10000 Firmware Revision: HPDE Serial Number: 3NM57RF40000983878FX Model: HP DG146BB976 Current Temperature (C): 29 Maximum Temperature (C): 35 PHY Count: 2 PHY Transfer Rate: Unknown, Unknown physicaldrive 1I:1:2 Port: 1I Box: 1 Bay: 2 Status: OK Drive Type: Data Drive Interface Type: SAS Size: 146 GB Rotational Speed: 10000 Firmware Revision: HPDE Serial Number: 3NM55VQC000098388524 Model: HP DG146BB976 Current Temperature (C): 29 Maximum Temperature (C): 36 PHY Count: 2 PHY Transfer Rate: Unknown, Unknown Logical Drive: 2 Size: 546.8 GB Fault Tolerance: RAID 5 Heads: 255 Sectors Per Track: 32 Cylinders: 65535 Strip Size: 64 KB Full Stripe Size: 256 KB Status: OK Caching: Enabled Parity Initialization Status: Initialization Completed Unique Identifier: 600508B100184A395356573334550003 Disk Name: /dev/cciss/c0d1 Mount Points: None OS Status: LOCKED Logical Drive Label: A5C9C6F81504 Drive Type: Data Array: B Interface Type: SAS Unused Space: 0 MB Status: OK Array Type: Data physicaldrive 1I:1:3 Port: 1I Box: 1 Bay: 3 Status: OK Drive Type: Data Drive Interface Type: SAS Size: 146 GB Rotational Speed: 10000 Firmware Revision: HPDE Serial Number: 3NM2H5PE00009802NK19 Model: HP DG146ABAB4 Current Temperature (C): 30 Maximum Temperature (C): 37 PHY Count: 1 PHY Transfer Rate: Unknown physicaldrive 1I:1:4 Port: 1I Box: 1 Bay: 4 Status: OK Drive Type: Data Drive Interface Type: SAS Size: 146 GB Rotational Speed: 10000 Firmware Revision: HPDE Serial Number: 3NM28YY400009750MKPJ Model: HP DG146ABAB4 Current Temperature (C): 31 Maximum Temperature (C): 36 PHY Count: 1 PHY Transfer Rate: 3.0Gbps physicaldrive 2I:1:5 Port: 2I Box: 1 Bay: 5 Status: OK Drive Type: Data Drive Interface Type: SAS Size: 146 GB Rotational Speed: 10000 Firmware Revision: HPDE Serial Number: 3NM2FGYV00009802N3GN Model: HP DG146ABAB4 Current Temperature (C): 30 Maximum Temperature (C): 38 PHY Count: 1 PHY Transfer Rate: Unknown physicaldrive 2I:1:6 Port: 2I Box: 1 Bay: 6 Status: OK Drive Type: Data Drive Interface Type: SAS Size: 146 GB Rotational Speed: 10000 Firmware Revision: HPDE Serial Number: 3NM8AFAK00009920MMV1 Model: HP DG146BB976 Current Temperature (C): 31 Maximum Temperature (C): 41 PHY Count: 2 PHY Transfer Rate: Unknown, Unknown physicaldrive 2I:1:7 Port: 2I Box: 1 Bay: 7 Status: OK Drive Type: Data Drive Interface Type: SAS Size: 146 GB Rotational Speed: 10000 Firmware Revision: HPDE Serial Number: 3NM2FJQD00009801MSHQ Model: HP DG146ABAB4 Current Temperature (C): 29 Maximum Temperature (C): 39 PHY Count: 1 PHY Transfer Rate: Unknown

    Read the article

  • Shorten array length once element is remove in Java.

    - by lupin
    Note: Following is my homework/assignment, feel free not to answer if you will. I want to delete/remove an element from an String array(Set) basic, I'm not allowed to use Collections..etc. Now I have this: void remove(String newValue) { for ( int i = 0; i < setElements.length; i++) { if ( setElements[i] == newValue ) { setElements[i] = ""; } } } I does what I want as it remove the element from an array but it doesn't shorten the length. The following is the output, basically it remove the element indexed #1. D:\javaprojects>java SetsDemo Enter string element to be added A You entered A Set size is: 5 Member elements on index: 0 A Member elements on index: 1 b Member elements on index: 2 hello Member elements on index: 3 world Member elements on index: 4 six Set size is: 5 Member elements on index: 0 A Member elements on index: 1 Member elements on index: 2 hello Member elements on index: 3 world Member elements on index: 4 six lupin

    Read the article

  • [Java/Android] Multidimensional array to ListView.. how?

    - by Yverman
    I have a query result set which I like to edit first and then put it to my ListView. Without editing my data first, I could use SimpleCursorAdapter like that: ListAdapter adapter = new SimpleCursorAdapter( this, R.layout.list_item, mCursor, new String[] { "address", "city" }, new int[] { R.id.address, R.id.zip_city }); this.setListAdapter(adapter); But now, I put everything in a multidimensional array like that: if(mCursor.isFirst()) { //create a new array String[][] listData = new String[mCursor.getCount()][3]; int i = 0; do { listData[i] = new String[] { mCursor.getString(mCursor.getColumnIndex("address")), mCursor.getString(mCursor.getColumnIndex("zip")) + " " + mCursor.getString(mCursor.getColumnIndex("city")), calculateDistance(Double.parseDouble(mCursor.getString(mCursor.getColumnIndex("diff")))) }; i++; } while(mCursor.moveToNext()); } So my problem is now, I have no idea how to put this to my ListView. Could someone help me here? Sorry for my bad english and Java knowledge. :)

    Read the article

  • How to save some values from an array in a controller in Rails?

    - by Alfred Nerstu
    I've got a links array that I'm saving to a database. The problem is that the records aren't saved in the order of the array ie links[1] is saved before links[2] and so on... This is a example from the view file: <p> <label for="links_9_label">Label</label> <input id="links_9_name" name="links[9][name]" size="30" type="text" /> <input id="links_9_url" name="links[9][url]" size="30" type="text" /> </p> And this is my controller: def create @links = params[:links].values.collect { |link| @user.links.new(link) } respond_to do |format| if @links.all?(&:valid?) @links.each(&:save!) flash[:notice] = 'Links were successfully created.' format.html { redirect_to(links_url) } else format.html { render :action => "new" } end end end Thanks in advance! Alfred

    Read the article

  • php writing array in a text file fails, why?

    - by Tarique Imam
    trying to write an array to a text file, but it is failed, can anybody say, WHY? $filename= 't12a'; for ($pnum = 1; $pnum <= 15; $pnum++){ $bbal = 3; $ipmnt = 14 * 5; $ppmnt = 26 - 7; $ebal = 48 - 4; $ccint = 54 + 45; $cpmnt = 25 + 54; $db_data_txt[] = array('pn' => $pnum, 'bb' => sprintf("%01.2f",$bbal),'ip'=>sprintf("%01.2f",$ipmnt),'pp'=>sprintf("%01.2f",$ppmnt),'eb'=>sprintf("%01.2f",$ebal),'ci'=>sprintf("%01.2f",$ccint),'cp'=>sprintf("%01.2f",$cpmnt)); } $con= $db_data_txt; if ( ! write_file("./files/{$filename}.doc", $con)) { echo 'Unable to write the file'; } else { echo 'File written!'; }

    Read the article

  • How to sort some values from an array in a controller in Rails?

    - by Alfred Nerstu
    I've got a links array that I'm saving to a database. The problem is that the records aren't saved in the order of the array ie links[1] is saved before links[2] and so on... This is a example from the view file: <p> <label for="links_9_label">Label</label> <input id="links_9_name" name="links[9][name]" size="30" type="text" /> <input id="links_9_url" name="links[9][url]" size="30" type="text" /> </p> And this is my controller: def create @links = params[:links].values.collect { |link| @user.links.new(link) } respond_to do |format| if @links.all?(&:valid?) @links.each(&:save!) flash[:notice] = 'Links were successfully created.' format.html { redirect_to(links_url) } else format.html { render :action => "new" } end end end Thanks in advance! Alfred

    Read the article

  • How do I return specific keys from the $_POST array?

    - by Brook
    I would like to check to see if there are any keys in $_POST that contain a string. The string will not be the full key, only part of the key. (ie. search string = "delRowID", $_POST key = "delRowID_16"). I have tried to use array_keys($_POST,"delRowID"), but it has never returned anything. CODE print_r($_POST); print_r(array_keys($_POST,"delRowID")); RETURNS Array ( [delRowID] => 29 [qAction] => [elmUpdateId] => [elmTtl] => [elmDesc] => [elmStr] => ) Array ( )

    Read the article

  • Why does javascript's "in" operator return true when testing if 0 exists in an array that doesn't co

    - by Mariano Peterson
    For example, this returns true, and makes sense: var x = [1,2]; 1 in x; // true This returns false, and makes sense: var x = [1,2]; 3 in x; // false However this returns true, and I don't understand why: var x = [1,2]; 0 in x; You can quickly test it by putting this in your browser's address bar: javascript:var x=[1,2]; alert(0 in x); Why does the "in" operator in Javascript return true when testing if "0" exists in array, even when the array doesn't appear to contain "0"?

    Read the article

  • for loop with count from array, limit output? PHP

    - by Philip
    print '<div id="wrap">'; print "<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">"; for($i=0; $i<count($news_comments); $i++) { print ' <tr> <td width="30%"><strong>'.$news_comments[$i]['comment_by'].'</strong></td> <td width="70%">'.$news_comments[$i]['comment_date'].'</td> </tr> <tr> <td></td> <td>'.$news_comments[$i]['comment'].'</td> </tr> '; } print '</table></div>'; $news_comments is a 3 diemensional array from mysqli_fetch_assoc returned from a function elsewhere, for some reason my for loop returns the total of the array sets such as [0][2] etc until it reaches the max amount from the counted $news_comments var which is a return function of LIMIT 10. my problem is if I add any text/html/icons inside the for loop it prints it in this case 11 times even though only array sets 1 and 2 have data inside them. How do I get around this? My function query is as follows: function news_comments() { require_once '../data/queries.php'; // get newsID from the url $urlID = $_GET['news_id']; // run our query for newsID information $news_comments = selectQuery('*', 'news_comments', 'WHERE news_id='.$urlID.'', 'ORDER BY comment_date', 'DESC', '10'); // requires 6 params // check query for results if(!$news_comments) { // loop error session and initiate var foreach($_SESSION['errors'] as $error=>$err) { print htmlentities($err) . 'for News Comments, be the first to leave a comment!'; } } else { print '<div id="wrap">'; print "<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"3\">"; for($i=0; $i<count($news_comments); $i++) { print ' <tr> <td width="30%"><strong>'.$news_comments[$i]['comment_by'].'</strong></td> <td width="70%">'.$news_comments[$i]['comment_date'].'</td> </tr> <tr> <td></td> <td>'.$news_comments[$i]['comment'].'</td> </tr> '; } print '</table></div>'; } }// End function Any help is greatly appreciated.

    Read the article

  • Get array's key recursively and create underscore seperated string.

    - by Nehal
    Hello Everyone, Right now i got an array which has some sort of information and i need to create a table from it. e.g. Student{ [Address]{ [StreetAddress] =>"Some Street" [StreetName] => "Some Name" } [Marks1] => 100 [Marks2] => 50 } Now I want to create database table like which contain the fields name as : Student_Address_StreetAddress Student_Address_StreetName Student_Marks1 Student_Marks2 It should be recursive so from any depth of array it can create the string in my format.

    Read the article

  • How can I access this nested array within my JSON object?

    - by Charles
    I'm using PHP to return a json_encode()'d array for use in my Javascript code. It's being returned as: {"parent1[]":["child1","child2","child2"],"parent2[]":["child1"]} By using the following code, I am able to access parent2 > child1 $.getJSON('myfile.php', function(data) { for (var key in data) { alert(data[key]); } } However, this doesn't give me access to child1, child2, child, of parent1. Alerting the key by itself shows 'parent1' but when I try to alert it's contents, I get undefined. I figured it would give me an object/array? How do I access the children of parent1? data[key][0] ?

    Read the article

  • How can I use Linq to create an array of dictionaries from XML?

    - by Duke
    Given the following XML structure: <courses> <course> <title>foo</title> <description>bar</description> </course> ... </courses> How could I create an array of dictionaries such that each dictionary contains all the element/value pairs within a course? What I have right now generates an array whose elements contain a single key/value dictionary for each element/value pair in a course: XElement x = XElement.Parse("...xml string..."); var foo = (from n in x.Elements() select n) .Elements().ToDictionary(y => y.Name, y => y.Value); Produces: [0] => {[course, foo]} [1] => {[description, bar]} What I'd like is this: [0] => {[course, foo], [description, bar]}

    Read the article

  • Best way to pass a 2d array into javascript from php?

    - by 133794m3r
    Ok, what i'm trying to do here is to pass a 2d array from php to javascript in the easiest way possible. The main reason for this is because i have the array which is previously filled with data via the phpscript and doing it one by one and just "calling it as it's needed" will not work out too well since well there's more than just one row required when it's called and i'd rather not do something like for all of the elements in it as it's number is unknown until it gets said data from the database. I was going to do a while loop to write in some of the data into elements sot hat it coudl be later pulled up more easily but i cannot seem to find an easy way to do this currently. If anyone has an easy way to transfer this to javascript without having to do what i previously said.

    Read the article

< Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >