Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

php - Can any one give me some advice to make my for loop more efficient? -


so have loop 36 if-queries inside. advice on making more efficient? can view complete code here

here's sample of looks like:

$numbers = range(1, 36); shuffle($numbers);   ($m =0; $m<37; $m++){     if ($numbers[$m] == "1"){         $mirza[$m] = "ruthie";         $mage[$m] = "3";         $mquote[$m] = "i learn lot of new things here, sign language!";         $link[$m] = "http://www.google.com";     }      if ($numbers[$m] == "2"){         $mirza[$m] = "aida";         $mage[$m] = "82";         $mquote[$m] = "this club , know , members. it's therapy.";         $link[$m] = "/about/";     }      if ($numbers[$m] == "3"){         $mirza[$m] = "amire";         $mage[$m] = "4";         $mquote[$m] = "i learning how share , make friends.";         $link[$m] = "/about/";     } } 

when have data should in database (maybe xml or document style) or text file.

still, i'll show way improve hard-coding data in 1 place , eliminating need if or switch statements. should @ least change switch statements, better still hard-code data in 1 place (below), better still database or csv text file storing these values.

$data = array(           array('mirza' => 'ruthie', 'mage' => '3', 'mquote' => 'i learn lot of new things here, sign language!', 'link' => 'http://www.google.com'),          array(......              );  $numbers = range(1, 36); shuffle($numbers);   ($m =0; $m<37; $m++){      $index = $numbers[$m];      $mirza[$m] = $data[$index]['mirza'];      $mage[$m] = $data[$index]['mage'];      $mquote[$m] = $data[$index]['mage'];      $link[$m] = $data[$index]['link'];  } 

just clear, 'efficiency' issue here isn't speed (though way faster). have nightmare maintain , change.

you might better reconsider design of app, making object mirza, mage, mquote, link fields.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -