for-loop

Get the values from $i , with disturbed order

橙三吉。 提交于 2020-01-22 03:47:06
问题 for ($i = 0; $i < count($name); $i++) { //some output ommited <td><input type='submit' value='Purchase' name='$name[$i]'></td></tr>"; } $name[$i] = name1, name2, name3 , name4 , name5 , name6 Now once the button is clicked, this is what I should be displaying. if (isset($_REQUEST['name1'])) {echo "name1 selected";} if (isset($_REQUEST['name2'])) {echo "name2 selected";} if (isset($_REQUEST['name3'])) {echo "name3 selected";} if (isset($_REQUEST['name4'])) {echo "name4 selected";} if (isset($

closure in for-loop > different tries failed

烈酒焚心 提交于 2020-01-22 03:42:09
问题 I want to create a 2-dimensional array with an index-number in each first element. EDIT: thx a lot so far.. @carl: I did so much function creation just to show the kind of tries I did.. jonhopkins idea gave rise to this: this works: $('#create_indexed_array').click(function() { var new_array = [[9,9],[9,9],[9,9],[9,9],[9,9]]; for (var i = 0; i < 5; i++) { new_array[i][0] = i; } alert(JSON.stringify(new_array)); }); BUT this works not: $('#create_indexed_array').click(function() { var new

How do I properly loop through the subplots of a matplotlib figure to show the final y-axis value of each line?

浪尽此生 提交于 2020-01-22 03:32:04
问题 I currently have a matplotlib figure with 16 subplots, 4 columns and 4 rows. I have the following code produced that loops through each subplot and plots different data on each of the 16 subplots: fac_list = [one, two, three, four, five, six, seven, eight, nine, ten , eleven, twelve, thirteen, fourteen, fifteen, sixteen] color = ['blue','red'] ds_i = 0 for row in range(0,subplot_shape[0]): for col in range(0,subplot_shape[1]): fac = fac_list[ds_i] plot('total', currentname=fac, subplot_index=

Dividing a matrix into two parts

僤鯓⒐⒋嵵緔 提交于 2020-01-22 02:56:08
问题 I am trying to classify my dataset. To do this, I will use the 4th column of my dataset. If the 4th column of the dataset is equal to 1, that row will added in new matrix called Q1 . If the 4th column of the dataset is equal to 2, that row will be added to matrix Q2 . My code: i = input('Enter a start row: '); j = input('Enter a end row: '); search = importfiledataset('search-queries-features.csv',i,j); [n, p] = size(search); if j>n disp('Please enter a smaller number!'); end for s = i:j

Setting event handlers using a for loop [duplicate]

陌路散爱 提交于 2020-01-22 02:51:08
问题 This question already has answers here : How to generate event handlers with loop in Javascript? [duplicate] (3 answers) Closed 6 years ago . I was messing around with some javascript, on jsfiddle, and ran into a strange issue. I can't seem to figure out why I am unable to set onclick event handlers via a for loop: html: <table border="1" cellspacing="1" width="500"> <tr id="headerRow"> <td>Header1</td> <td>Header2</td> <td>Header3</td> <td>Header4</td> </tr> <tr> <td>books</td> <td>red</td>

Python for loop returns True after first item

倾然丶 夕夏残阳落幕 提交于 2020-01-22 02:42:09
问题 def checker(a_list): for item in a_list: if str(item).isdigit(): return True else: return False The variable I have for checker is a list of four string containing variables. I planned to use it as a 'checker' to see if all input values of another function contained only digits. Problem: If the first item in a_list is not a number, checker returns False as it should. However, if the first item is a number while any others in the list aren't, checker returns True anyways. This causes the next

How to disemvowel a string with a condition where if the letter “g” is right beside a vowel, it would also be considered a vowel?

我怕爱的太早我们不能终老 提交于 2020-01-22 02:34:12
问题 Working on a homework question where all the vowels in a string need to be removed and if the letter "g" is beside a vowel, it would also be considered a vowel. For example given the string "fragrance" I want the string returned to say "frrnc" This is what I have so far: def disemvowel(text): text = list(text) new_letters = [] for i in text: if i.lower() == "a" or i.lower() == "e" or i.lower() == "i" or i.lower() == "o" or i.lower() == "u": pass else: new_letters.append(i) print (''.join(new

Multiple Automatic Reports with Subgroup Loop in R

烈酒焚心 提交于 2020-01-22 02:32:04
问题 I'm trying to create automated PDF RMarkdown reports for fitness testing data based on the training hub city. I believe I'm very close by following the outline here: R Knitr PDF: Is there a posssibility to automatically save PDF reports (generated from .Rmd) through a loop? However, this is creating reports with the same data for only 1 hub despite both being named differently (report.MTL.pdf and report.TOR.pdf). How can I get the subgroup to loop properly to show data from the different hubs

For loop with an argument based range

南笙酒味 提交于 2020-01-21 19:29:05
问题 I want to run certain actions on a group of lexicographically named files (01-09 before 10). I have to use a rather old version of FreeBSD (7.3), so I can't use yummies like echo {01..30} or seq -w 1 30 . The only working solution I found is printf "%02d " {1..30} . However, I can't figure out why can't I use $1 and $2 instead of 1 and 30 . When I run my script ( bash ~/myscript.sh 1 30 ) printf says {1..30}: invalid number AFAIK, variables in bash are typeless, so how can't printf accept an

How to concat variable integer in control name in vb.net

隐身守侯 提交于 2020-01-21 10:25:20
问题 Now I have a database and pull out that data and display it to form,i have a sequence of groupbox and radiobuttons, in each groupbox (groupbox1,groupbox2,etc...) there are 2 radio buttons namely rdbtn1Yes and rdbtn1No (then it increment +1 in next Groupbox). now i use for loop to go through every groupboxes and radio buttons. And this is my code: Dim sqlda As New SqlDataAdapter("SELECT * FROM table1 WHERE column1= '" & lblWONo.Text & "'", Constr) Dim sqlds As New DataSet sqlds.Clear() sqlda