Jump to content

amalafrida

Members
  • Posts

    25
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

amalafrida's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. All of the foregoing 'impolitesse' to the contrary notwithstanding, the non-obvious (at least to me) solution appears to be the code I've posted below. Any suggestions or advice will be greatly appreciated. given this Array: ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 42 [5] => 42 [6] => 42 [7] => 42 [8] => 36 [9] => 36 [10] => 0 [11] => 36 [12] => 36 [13] => 36 [14] => 36 [15] => 36 [16] => 42 [17] => 42 [18] => 42 [19] => 42 [20] => 42 [21] => 42 [22] => 42 [23] => 0 ) how to get to this description of the array: index 0 to index 4 = 0 index 4 to index 8 = 42 index 8 to index 16 = 36 index 16 to index 23 = 42 index 23 = 0 $startIndex = 0; $endIndex = 0; $lastVal = $val[0]; for($i=1; $i<25; $i++) { if ($val[$i] == $lastVal) { $endIndex = $i; } else { if($endIndex==23) $term="00:00"; else $term=($endIndex+1) . ":00"; if($lastVal!=0) $report.=$lastVal . "<br>" . ($startIndex) . ":00 to: " . $term . "<br>"; $startIndex = $i; $endIndex = $i; $lastVal = $val[$i]; } }
  2. In the interest of brevity, I did not post the code that generated the array. That struck me as the courteous approach, rather than burdening the list with unnecessary verbiage. I fail to understand your assumption that this is an "assignment". And I certainly do not appreciate your censorious responses. Let me repeat: I did not post an assignment and say that I don't know what to do. I posed a problem I'd been working with for quite some time and asked for some assistance, advice. A post to "stack overflow", phrased exactly as the post that began this thread, elicited a lucid and kind respose within 15 min. ... not a full solution, but advice, respectful and patient, sufficient to permit me to solve my "non-assignment". I will no doubt work with that group in the future or at least await responses on this list from members other than yourself. Would it be incendiary of me to suggest that you look into "charm" lessons?
  3. Well, thanks, advanced member, I guess. However, I did not believe myself to be asking for homework help. Only perhaps a bit of lucid advice. Your reply falls remarkably short on lucidity, a bit too far on moralizing ... (don't ask us to do your homework, don't ask us to write your code for you, the answer is obvious ... do it yourself). Just a bit of advice beyond the obvious lies at the heart of my request. Yes, "foreach/for" strikes me too as altogether obvious, but the part between the braces not so obvious for a "non-freak" "non-guru" type. Will keep casting about, however, for further suggestions.
  4. what sort of php array enumeration must I use to get from this: Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 42 [5] => 42 [6] => 42 [7] => 42 [8] => 36 [9] => 36 [10] => 0 [11] => 36 [12] => 36 [13] => 36 [14] => 36 [15] => 36 [16] => 42 [17] => 42 [18] => 42 [19] => 42 [20] => 42 [21] => 42 [22] => 42 [23] => 0 ) to this description of the array: index 0 to index 4 = 0 index 4 to index 8 = 42 index 8 to index 16 = 36 index 16 to index 23 = 42 index 23 = 0 my head is swirling with conditionals and loops ... getting dizzy ... can't crack it. thanks in advance for any assistance.
  5. still foggy. are you then suggesting that the table be structured as follows: each row should contain 2 cells ... 1) a timestamp cell 2) one cell containing 24 text boxes? thanks for your patience.
  6. I don't understand your "timestamp/column" comment. The first cell of each row carries a timestamp. a typical row resembles the following: <td> <input type='text' name='date[1345438800]' value='Mon-20-Aug' /></td> <td> <input type='text' name='datacell[0]' value='Z' /> </td> .... <td> <input type='text' name='datacell[23]' value='A' /> </td> I'm looping through and picking up each day's sequence of 24 values and placing them into an array ... key=timestamp value=24 letter codes ... then to the database with it ... user is free to modify any of the available text boxes.
  7. should have specified: each POST element looks like this: <td> <input type='text' name='datacell[5]' value='I' /></td>
  8. Trying to POST values from a table ... each table cell represents 1 hour of each day for 6 months ... total approx. 4000 the cells are named datacell[0] ... datacell[4000] however, when i foreach($_POST['datacell'] as $key=>$val) { $codes.=$val; } echo strlen($codes); strlen is only 1001 ... same if I push them into an array any suggestions? beginning to think I have reached an unwieldy limit here ... break the calendar up ... present only one month at a time?
  9. Yes, a letter can repeat. Am interested in elaboration of this observation by Jesirose: "While I don't agree with the reasoning behind this, here's a function." And yes, just counting characters. Thanks for all the help.
  10. what would be the best way to generate this string 7a3b7c4d10e from this string aaaaaaabbbcccccccddddeeeeeeeeee I have many 10,000s of strings of this sort, 168 characters each to store in database. attempting to minimize storage space. ??? thanks in advance
  11. is this the proper forum to pose a pear install question?
  12. yes! that is precisely what I was looking for. saves me two trips to the database and much unnecessary parsing. once again, many thanks.
  13. I have 5 items in the select/combo box when I _POST that item, I am returned the text contained in the box. BUT, can I know WHICH of the 5 items in the combo box it is? i.e. can I get its index number? ............. ok, yes. thanks. I feared I was skirting that treacherous line betwixt the 2. thanks for the help. you folks are invariably straight up, spot on, not to mention accurate.
  14. $_POST['select'] permits me access to the selected value of my combo box named 'select'. are any other attributes of the box accessible? in particular, index # ... etc.? thanks in advance for any light you might shed on the topic.
  15. SOLVED
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.