Categories > TinyButStrong general >

Problem with array (URGENT!)

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Flavio
Date: 2006-01-06
Time: 19:36

Problem with array (URGENT!)

Im having this problem with the TBS.

I have a array that show the following result.

array(32) { [21]=>  array(9) { [0]=>  string(8) "23:10:12" [1]=>  string(8) "23:16:12" [2]=>  string(8) "23:21:12" [3]=>  string(8) "23:27:12" [4]=>  string(8) "23:33:12" [5]=>  string(8) "23:40:13" [6]=>  string(8) "23:45:13" [7]=>  string(8) "23:51:12" [8]=>  string(8) "23:56:12" }

For example, I need to show in a column the results of $dates_times[21][0] to $dates_times[21][9];

What it the code in the HTML to do this?

Im using the following TBS sintax in PHP:

$TBS->MergeBlock('blk2',$dates_times);

And in the HTML:

<td>[blk2.day.#;block=tr;frm='hh:nn']</td>

But im getting an error. Please, any one can help me?
By: Skrol29
Date: 2006-01-06
Time: 19:53

Re: Problem with array (URGENT!)

Hello Flavio,

Of course your block is not correct because there is no 'day' key in your array.

This should work.
PHP:
$TBS->MergeBlock('blk2',$dates_times[21]);

HTML:
<tr><td>[blk2.val;block=tr;frm='hh:nn']</td></tr>

'val' is a virtual TBS column for simple array.
By: Flavio
Date: 2006-01-06
Time: 20:01

Re: Problem with array (URGENT!)

Hello!

Sorry, I correct the array now. Here's the array.

array(571) { [20]=>  array(2) { ["day"]=>  int(21) [0]=>  string(8) "23:10:12" } [21]=>  array(2) { ["day"]=>  int(21) [1]=>  string(8) "23:16:12" } [22]=>  array(2) { ["day"]=>  int(21) [2]=>  string(8) "23:21:12" } [23]=>  array(2) { ["day"]=>  int(21) [3]=>  string(8) "23:27:12" } [24]=>  array(2) { ["day"]=>  int(21) [4]=>  string(8) "23:33:12" } [25]=>  array(2) { ["day"]=>  int(21) [5]=>  string(8) "23:40:13" } [26]=>  array(2) { ["day"]=>  int(21) [6]=>  string(8) "23:45:13" } [27]=>  array(2) { ["day"]=>  int(21) [7]=>  string(8) "23:51:12" } [28]=>  array(2) { ["day"]=>  int(21) [8]=>  string(8) "23:56:12" }

I need to display the "hours" that are in the array. What should I do?
By: Skrol29
Date: 2006-01-09
Time: 10:15

Re: Problem with array (URGENT!)

Hello Flavio,

For merging a normal array, this one should be structured as a list of records having the same structure (that is the same columns). But your array is not structured this way. It has a colmuns which changes its key on each record :
[0] => '23:10:12'
[1] => '23:16:12'
[2] => '23:21:12'
...

What I suggest to you is to use a block with parameter "ondata" in order to calculate a column with a fixed name. And then you can merge the time value.

Example :
PHP :
$TBS->MergeBlock('blk2',$my_array);
...
function f_add_column($BlockName,&$CurrRec,$RecNum) {
  $CurrRec['hour'] = $CurrRec[$RecNum-1];
}

HTML :
  <tr>
    <td>
      [blk2.val;block=tr;ondata=f_add_column;frm='hh:nn']
    </td>
  </tr>